{"id":275820,"date":"2016-03-10T10:30:03","date_gmt":"2016-03-10T07:30:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=275820"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=275820","title":{"rendered":"\u0427\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0436\u0434\u0435\u0442 \u043d\u0430\u0441 \u0432 Laravel 5.2.23"},"content":{"rendered":"<p>       \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 Laravel \u043d\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0443\u0436\u0435 911 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u043d\u0430 GitHub, \u043c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043d\u043e\u0432\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0442\u043e \u0436\u0435 \u0436\u0434\u0435\u0442 \u043d\u0430\u0441 \u043d\u043e\u0432\u0435\u043d\u044c\u043a\u043e\u0433\u043e \u0432 Laravel 5.2.23.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/f6a\/778\/abd\/f6a778abdb6743728cd6cf28e7bccdee.jpg\" alt=\"image\"\/><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041d\u043e\u0432\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 in_array<\/h2>\n<p>  \u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0432 laravel \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0437\u0443\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0449\u044c, \u044f \u043b\u0438\u0447\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u043b \u043a\u0443\u0447\u0443 \u043a\u043e\u0434\u0430 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043d\u0430 \u043f\u0430\u0440\u0443 \u0441\u0442\u0440\u043e\u043a \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438.<br \/>  \u0412 5.2.23 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e. \u041e\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0435:<\/p>\n<pre><code>Validator::make(     [         'devices' =&gt; [['user_id' =&gt; 1], ['user_id' =&gt; 2]],         'users' =&gt; [['id' =&gt; 1, ['id' =&gt; 2]]]     ],     ['devices.*.user_id' =&gt; 'in_array:users.*.id'] ); <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f user_id \u0443 devices \u0441\u043e\u043e\u0442\u0432\u0435\u0442c\u0432\u0443\u044e\u0442 \u043a\u043b\u044e\u0447\u0430\u043c id \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 users .<\/p>\n<h2>\u0423 Arr::first() &amp; Arr::last() \u043a\u043e\u043b\u043b\u0431\u0435\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u0435\u043d<\/h2>\n<p>  \u0420\u0430\u043d\u0435\u0435 \u043a\u043e\u043b\u043b\u0431\u0435\u043a \u0431\u044b\u043b \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u0435\u043d \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u0442:<\/p>\n<pre><code>$array = [100, 200, 300]; \/\/ \u041f\u043e \u041d\u041e\u0412\u041e\u041c\u0423  \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u0435\u0440\u043d\u0435\u0442 100 Arr::first($array); \/** \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0447\u0442\u043e \u0438  **\/ array_first($array); \/\/ \u041f\u043e \u041d\u041e\u0412\u041e\u041c\u0423  \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u0435\u0440\u043d\u0435\u0442 300 Arr::last($array); \/**\u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0447\u0442\u043e \u0438  **\/ array_last($array); \/\/ \u041c\u043e\u0436\u043d\u043e \u0438 (\u043a\u0430\u043a \u0420\u0410\u041d\u042c\u0428\u0415)  \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c 200 Arr::first($array, function ($key, $value) {     return $value &gt;= 150; });<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0423\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u0430(middleware) \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e<\/h2>\n<p>  \u0412 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0438 \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439.<\/p>\n<pre><code>$this-&gt;middleware(['auth', 'subscribed'], ['only' =&gt; ['getCandy']]);<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041d\u043e\u0432\u044b\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b Blade  <a href=\"https:\/\/habrahabr.ru\/users\/php\/\" class=\"user_link\">php<\/a>,  @endphp, \u0438  <a href=\"https:\/\/habrahabr.ru\/users\/unset\/\" class=\"user_link\">unset<\/a><\/h2>\n<p>  \u0414\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430  <a href=\"https:\/\/habrahabr.ru\/users\/php\/\" class=\"user_link\">php<\/a> \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u0438\u0441\u0430\u0442\u044c PHP \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>@php($count = 1)  @php(++ $count)  @php $now = new DateTime(); $environment = isset($env) ? $env : &quot;testing&quot;; @enphp<\/code><\/pre>\n<p>   <a href=\"https:\/\/habrahabr.ru\/users\/unset\/\" class=\"user_link\">unset<\/a> \u2014 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u0434\u043b\u044f unset().<\/p>\n<pre><code>@unset($count)<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b Blade<\/h2>\n<p>  \u0414\u043e \u0432\u0435\u0440\u0441\u0438\u0438 5.2.23 \u0431\u044b\u043b\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c Blade \u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b, \u0442\u0435\u043f\u0435\u0440\u044c \u043b\u044e\u0431\u043e\u0435 \u0432\u0430\u0448\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0443.<\/p>\n<h2>\u041d\u043e\u0432\u044b\u0439 \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0434\u043b\u044f SparkPost<\/h2>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/331\/1bc\/ef2\/3311bcef2c6b42fc924b88b1dbf9377d.jpg\"\/><\/p>\n<h2>\u041d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 monthlyOn() \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u043f\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e<\/h2>\n<p>  <\/p>\n<pre><code>$schedule-&gt;call(function () {     DB::table('shopping_list')-&gt;delete(); })-&gt;monthlyOn(4, '12:00');<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 app()-&gt;isLocale()<\/h2>\n<p>  <\/p>\n<pre><code>\/\/ \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e if (app()-&gt;getLocale() == 'en') \/\/ \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c if (app()-&gt;isLocale('en'))<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0412\u044b\u0431\u043e\u0440\u043a\u0438 \u043f\u043e JSON \u043f\u043e\u043b\u044f\u043c \u0432 MySQL 5.7 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/h2>\n<p>  \u0412 MySQL 5.7 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u2014 JSON, \u0412 Laravel 5.2.23 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043f\u043e \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044f\u043c \u0442\u0430\u043a\u0436\u0435 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u043a\u0430\u043a \u0438 \u043e\u0431\u044b\u0447\u043d\u043e.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0430 users \u0441 \u043a\u043e\u043b\u043e\u043d\u043a\u043e\u0439 name \u0442\u0438\u043f\u0430 JSON, \u043f\u043e\u043b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430:<\/p>\n<pre><code>{&quot;en&quot;:&quot;name&quot;,&quot;ar&quot;:&quot;nom&quot;}<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435<\/p>\n<pre><code>User::where('name-&gt;en', 'name')-&gt;get(); \/\/ \u0423\u0433\u043b\u0443\u0431\u0438\u0442\u044c\u0441\u044f \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 JSON \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438  \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 `-&gt;`. User::where('contacts-&gt;phone-&gt;home', 1234);<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f seeElement() \u0438 dontSeeElement()<\/h2>\n<p>  \u0415\u0441\u043b\u0438 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442<\/p>\n<pre><code>&lt;image width=&quot;100&quot; height=&quot;50&quot;&gt;<\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430:<\/p>\n<pre><code>$this-&gt;seeElement('image', ['width' =&gt; 100, 'height' =&gt; 50]);<\/code><\/pre>\n<p>  \u0418\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430  c \u043a\u043b\u0430\u0441\u0441\u043e\u043c video<\/p>\n<pre><code>$this-&gt;dontSeeElement('image', ['class' =&gt; 'video']);<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041c\u0430\u043b\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u043f\u043b\u044e\u0448\u043a\u0438<\/h2>\n<p>  \u0412\u044b \u0437\u043d\u0430\u043b\u0438, \u0447\u0442\u043e \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a?<\/p>\n<pre><code>User::whereNameAndEmail('jon', 'jon@theWall.com')-&gt;first(); User::whereNameAndEmailOrPhone('jon', 'jon@theWall.com', '123321')-&gt;first(); DB::table('users')-&gt;whereEmailOrUsername('mail@mail.com', 'themsaid')-&gt;first();<\/code><\/pre>\n<div class=\"clear\"><\/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:\/\/habrahabr.ru\/post\/278935\/\"> https:\/\/habrahabr.ru\/post\/278935\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 Laravel \u043d\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0443\u0436\u0435 911 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u043d\u0430 GitHub, \u043c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043d\u043e\u0432\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0442\u043e \u0436\u0435 \u0436\u0434\u0435\u0442 \u043d\u0430\u0441 \u043d\u043e\u0432\u0435\u043d\u044c\u043a\u043e\u0433\u043e \u0432 Laravel 5.2.23.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/f6a\/778\/abd\/f6a778abdb6743728cd6cf28e7bccdee.jpg\" alt=\"image\"\/>  <\/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-275820","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/275820","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=275820"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/275820\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=275820"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=275820"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=275820"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}