{"id":300360,"date":"2020-03-19T09:00:11","date_gmt":"2020-03-19T09:00:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=300360"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=300360","title":{"rendered":"\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 (\u0448\u043e\u0440\u0442\u043a\u043e\u0434\u043e\u0432) \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a \u0432 Laravel"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/492982\/\">\n<h3 id=\"vvedenie\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u043e\u0432 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430. \u0420\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u043f\u043e \u0440\u0430\u0437\u043d\u043e\u043c\u0443, \u043a\u0442\u043e \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <em>str_replace()<\/em>, \u043a\u0442\u043e \u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u043e\u0438\u0441\u043a \u0438 \u0437\u0430\u043c\u0435\u043d\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043e\u043a, \u0430 \u043a\u0442\u043e \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gu\/0u\/r4\/gu0ur4ooqm6bmyirjx8ntd2dcaw.png\"><\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u043f\u0440\u0438 \u0438\u0445 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u0432 \u0411\u0414 (\u0438\u043c\u044f \u0441\u0442\u0430\u0442\u044c\u0438, \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438)<\/li>\n<li>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438 \u0432\u044b\u0432\u043e\u0434 \u0421\u0415\u041e \u043c\u0435\u0442\u0430\u0442\u0435\u0433\u043e\u0432 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0445<\/li>\n<li>\u0428\u0430\u0431\u043b\u043e\u043d\u044b email \u043f\u0438\u0441\u0435\u043c \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 <\/li>\n<li>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f url-\u043f\u0443\u0442\u0435\u0439, \u0441\u043b\u0430\u0433\u043e\u0432<\/li>\n<li>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438 \u0432\u044b\u0432\u043e\u0434 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0443<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 CMS, \u044d\u0442\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0440\u0435\u0448\u0430\u044e\u0442\u0441\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u043c \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 (Drupal) \u0438\u043b\u0438 \u0448\u043e\u0440\u0442\u043a\u043e\u0434\u043e\u0432 (WordPress) \u0438\u043b\u0438 &quot;\u0436\u0435\u0442\u043e\u043d\u043e\u0432&quot;.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u041e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f &quot;\u0442\u043e\u043a\u0435\u043d\u0430&quot; \u043d\u0435\u0442. \u041c\u044b \u0436\u0435 \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<blockquote><p>\u0422\u043e\u043a\u0435\u043d\u044b (\u0448\u043e\u0440\u0442\u043a\u043e\u0434\u044b) \u2014 \u044d\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445, &quot;\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438&quot;, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u043c \u0442\u0435\u043a\u0441\u0442.<\/p><\/blockquote>\n<p>  <\/p>\n<h3 id=\"reshenie\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438 \u0432 Laravel, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/github.com\/fomvasss\/laravel-str-tokens\" rel=\"nofollow\">laravel-str-tokens<\/a><br \/>  \u0427\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0441\u0430\u0434 <strong>StrToken<\/strong>.<br \/>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0430\u043a\u0435\u0442\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430, \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043d\u0430 <a href=\"https:\/\/github.com\/fomvasss\/laravel-str-tokens\/blob\/master\/README.md\" rel=\"nofollow\">github<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043f\u0440\u0438\u043c\u0435\u0440: \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e \u0432 \u0411\u0414. \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0430\u043c\u043e \u0438\u043c\u044f \u0441\u0442\u0430\u0442\u044c\u0438, \u0438\u043c\u044f \u0430\u0432\u0442\u043e\u0440\u0430 \u0438 \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0434\u0430\u0442\u0430. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0438\u043c\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0434\u0430\u0435\u0442 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a \u044d\u0442\u043e\u043c\u0443 \u0438\u043c\u0435\u043d\u0438, \u0438\u043c\u044f \u0430\u0432\u0442\u043e\u0440\u0430 \u0438 \u0434\u0430\u0442\u0443. \u0417\u0430\u0434\u0430\u0434\u0438\u043c \u0448\u0430\u0431\u043b\u043e\u043d \u0438 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c \u043f\u043e\u043b\u043d\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u0442\u044c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">    public function store(Request $request)     {         $name = StrToken::setText($request-&gt;name . '[user:name]-[date:short]')             -&gt;setDate(\\Carbon\\Carbon::now())             -&gt;setEntity(Auth::user())             -&gt;replace();         \/\/ \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0441\u0442\u0430\u0442\u044c\u044e \u0441 $name \u0432 \u0411\u0414     }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <em>[user:name]-[date:date]<\/em> \u2014 \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043d\u0430\u0448\u0438 \u0442\u043e\u043a\u0435\u043d\u044b \u2014 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438, \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044b\u0435 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 \u201c<strong>[ ]<\/strong>\u201d. \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u044c (\u043e\u0431\u044c\u0435\u043a\u0442, \u043c\u043e\u0434\u0435\u043b\u044c) \u0438 \u0435\u0433\u043e \u043f\u043e\u043b\u0435 (\u043c\u0435\u0442\u043e\u0434, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440) \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u0435\u043c \u201c<strong>:<\/strong>\u201d<br \/>  <em>[user:name]<\/em> \u2014 user \u2014 \u0438\u043c\u044f Eloquent \u043c\u043e\u0434\u0435\u043b\u0438, name \u2014 \u043f\u043e\u043b\u0435 \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438<br \/>  <em>[date:short]<\/em> \u2014 date \u2014 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u0430\u0442\u044b Carbon, short \u2014 \u044d\u0442\u043e \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u0442\u044b<\/p>\n<p>  <\/p>\n<p>\u0424\u0430\u0441\u0430\u0434 <strong>StrToken<\/strong> \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<p>  <\/p>\n<ul>\n<li><em>setText(string)<\/em> \u2014 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u044b<\/li>\n<li><em>setDate(Carbon)<\/em> \u2014 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u0430\u0442\u044b Carbon. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u0442\u043e\u043a\u0435\u043d \u0432\u044b\u0434\u0430 [date:short], [date:time], [date:date]\u2026 \u2014 \u0448\u0430\u0431\u043b\u043e\u043d \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043f\u0430\u043a\u0435\u0442\u0430<\/li>\n<li><em>setEntity(Eloquent)<\/em> \u2014 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 Eloquent. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0442\u043e\u043a\u0435\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Article &amp; [article:name]<\/li>\n<li><em>setEntities(array)<\/em> \u2014 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043a\u0430\u043a setEntity, \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0436\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 Eloquent \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <em>[\u2018user1\u2019 =&gt; User::find(1), \u2018user2\u2019 =&gt; User::find(2), \u2018node\u2019 =&gt; Page::first()]<\/em><br \/>  \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0441\u0442\u0440\u043e\u043a \u0441 \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438: <em>[\u2018user1:name\u2019],[\u2018user2:city:name],[\u2018node:title\u2019]<\/em><\/li>\n<li><em>setVar(string, string)<\/em> \u2014 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u2014 \u043a\u043b\u044e\u0447 \u0438 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/li>\n<li><em>setVars(array)<\/em> \u2014 \u0441\u044e\u0434\u0430 \u043a\u0438\u0434\u0430\u0435\u043c \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u0422\u043e\u043a\u0435\u043d \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u043a\u0430\u043a \u0432\u044b\u0448\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 [var:length], [var:price]<\/li>\n<li><em>replace():string<\/em> \u2014 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u044b \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u044b \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432 Laravel, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043a\u0435\u043d\u044b \u0432\u0438\u0434\u0430:<br \/>  <em>[config:app.name], [config:mail.from.address],&#8230;<\/em><\/p>\n<p>  <\/p>\n<p>\u0417\u0430\u0434\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043f\u0430\u043a\u0435\u0442\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u0440\u044b\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u0438, \u0442\u043e\u043a\u0435\u043d\u044b \u0441\u0432\u043e\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u0442.\u0434.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438 \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">$str = StrToken::setText('     Example str with tokens for article: &quot;[article:title]([article:id])&quot;,     Article created at date: [article:created_at],     Author: [article:user:name]([article:user:id]).     User: [article:user:email], [article:user:city:country:title], [article:user:city:title].     Generated token at: [config:app.name], [date:raw]     [article:test:Hello]!!!     Length: [var:length];     Width: [var:width];     Price: [var:price] ')-&gt;setDate(\\Carbon\\Carbon::tomorrow())     -&gt;setEntity(\\App\\Model\\Article::findOrFail(13))     -&gt;setVars(['length' =&gt; '2.2 m.', 'width' =&gt; '3.35 m.'])     -&gt;setVar('price', '$13')     -&gt;replace();<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0443\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Example str with tokens for article: &quot;Test article title(23)&quot;, Article created at date: 15.07.2018, Author: Taylor Otwell(1), User: taylorotwell@gmail.com, AR, Little Rock. Generated token at: Laravel, 2018-10-27 00:00:00 TEST TOKEN:Hello!!!  Length: 2.2 m.; Width: 3.35 m.; Price: $13<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u044b\u0448\u0435 \u043c\u043e\u0433\u043b\u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u043f\u0430\u043a\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u044f\u0437\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0441 \u043d\u0438\u043c\u0438 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c: <em>[user2:city:name]<\/em>.<\/p>\n<p>  <\/p>\n<h3 id=\"itogi\">\u0418\u0442\u043e\u0433\u0438<\/h3>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 <a href=\"https:\/\/github.com\/fomvasss\/laravel-str-tokens\" rel=\"nofollow\">https:\/\/github.com\/fomvasss\/laravel-str-tokens<\/a>, \u043e\u0447\u0435\u043d\u044c \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043c\u043d\u043e\u0433\u0438\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 Laravel, \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u044b.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0441\u0442\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0434\u043b\u044f Eloquent \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u044b \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/492982\/\"> https:\/\/habr.com\/ru\/post\/492982\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/492982\/\">\n<h3 id=\"vvedenie\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u043e\u0432 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430. \u0420\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u043f\u043e \u0440\u0430\u0437\u043d\u043e\u043c\u0443, \u043a\u0442\u043e \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <em>str_replace()<\/em>, \u043a\u0442\u043e \u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u043e\u0438\u0441\u043a \u0438 \u0437\u0430\u043c\u0435\u043d\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043e\u043a, \u0430 \u043a\u0442\u043e \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gu\/0u\/r4\/gu0ur4ooqm6bmyirjx8ntd2dcaw.png\"><\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u043f\u0440\u0438 \u0438\u0445 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u0432 \u0411\u0414 (\u0438\u043c\u044f \u0441\u0442\u0430\u0442\u044c\u0438, \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438)<\/li>\n<li>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438 \u0432\u044b\u0432\u043e\u0434 \u0421\u0415\u041e \u043c\u0435\u0442\u0430\u0442\u0435\u0433\u043e\u0432 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0445<\/li>\n<li>\u0428\u0430\u0431\u043b\u043e\u043d\u044b email \u043f\u0438\u0441\u0435\u043c \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 <\/li>\n<li>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f url-\u043f\u0443\u0442\u0435\u0439, \u0441\u043b\u0430\u0433\u043e\u0432<\/li>\n<li>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438 \u0432\u044b\u0432\u043e\u0434 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0443<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 CMS, \u044d\u0442\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0440\u0435\u0448\u0430\u044e\u0442\u0441\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u043c \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 (Drupal) \u0438\u043b\u0438 \u0448\u043e\u0440\u0442\u043a\u043e\u0434\u043e\u0432 (WordPress) \u0438\u043b\u0438 &quot;\u0436\u0435\u0442\u043e\u043d\u043e\u0432&quot;.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-300360","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/300360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=300360"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/300360\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=300360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=300360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=300360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}