{"id":276238,"date":"2016-03-16T12:10:20","date_gmt":"2016-03-16T09:10:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=276238"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=276238","title":{"rendered":"\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c\u0438 \u0432 Laravel. \u0420\u0430\u0441\u0441\u044b\u043b\u043a\u0430 push \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0442\u0430\u0442\u044c\u0438"},"content":{"rendered":"<p>       \u0412 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043a \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043f\u0435\u0440\u0432\u044b\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u0432 \u043c\u043e\u0435\u043c \u0431\u043b\u043e\u0433\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u043b \u043c\u043d\u0435 \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0438\u0441 &quot;Onesignal&quot; \u041d\u0430 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u043b, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u0437\u0432\u0435\u0440\u044c \u0438 \u0441 \u0447\u0435\u043c \u0435\u0433\u043e \u0435\u0434\u044f\u0442. \u041f\u0440\u043e \u0441\u0430\u043c\u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u044f, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0437\u043d\u0430\u043b, \u043f\u0440\u043e \u0441\u0435\u0440\u0432\u0438\u0441 \u2014 \u043d\u0435\u0442.<br \/>  \u041b\u0435\u0433\u043a\u043e \u043d\u0430\u0433\u0443\u0433\u043b\u0438\u043b \u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0441\u0441\u044b\u043b\u0430\u0442\u044c push \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0430, \u043f\u043e \u0432\u0441\u0435\u043c \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u043c \u0438 \u0434\u0435\u0432\u0430\u0439\u0441\u0430\u043c. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u043c\u0435\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u0443\u044e \u043f\u0430\u043d\u0435\u043b\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\/\u043e\u0442\u0447\u0435\u0442\u043d\u043e\u0441\u0442\u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0438 \u0442\u0434.<br \/>  \u041d\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0443. \u0415\u0441\u0442\u044c \u0438 \u0435\u0433\u043e \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0438\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438, \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043b\u0435\u0433\u043a\u043e \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f. \u0414\u0430 \u0438 \u0440\u0435\u0447\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043e \u0441\u0430\u043c\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435, \u0430 \u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Laravel.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/laravel-news.ru\/attach\/d9\/5e\/56e4357ec3c65.jpg\"\/><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f<\/h2>\n<p>  \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 2 \u0447\u0430\u0441\u0442\u0438: \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0430 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0447\u0430\u0441\u0442\u0435\u0439:<\/p>\n<p>  1) \u041a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c: \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u043c javascript<\/p>\n<p>  2) \u0421\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c: \u043c\u044b \u043b\u044e\u0434\u0438 \u043b\u0435\u043d\u0438\u0432\u044b\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0443 Onesignal \u0438 \u043f\u043e\u0441\u0442\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u2013 \u043d\u0435 \u043d\u0430\u0448 \u043c\u0435\u0442\u043e\u0434. \u041d\u0430\u043c \u0431\u044b \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0443\u043c\u043d\u044b\u043c \u043c\u0430\u0448\u0438\u043d\u0430\u043c! \u0418, \u043e \u0447\u0443\u0434\u043e! \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443 onesignal \u0435\u0441\u0442\u044c JSON API. <\/p>\n<h2>\u041a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/h2>\n<p>  \u0422\u043e\u0436\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u0441\u0442\u0430\u043d\u0443, \u0442\u043a \u0432\u0441\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u0421\u043a\u0430\u0436\u0443 \u043b\u0438\u0448\u044c, \u0447\u0442\u043e \u0435\u0441\u0442\u044c 2 \u043f\u0443\u0442\u0438. \u041f\u0440\u043e\u0441\u0442\u043e\u0439: \u0442\u0443\u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0438\u0445 Javascript, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0442 \u043a\u043d\u043e\u043f\u043a\u0443 \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438. \u0418 \u0431\u043e\u043b\u0435\u0435 \u0434\u043e\u043b\u0433\u0438\u0439: \u0432\u0435\u0440\u0441\u0442\u0430\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0443 \u0440\u0443\u0447\u043a\u0430\u043c\u0438, \u043f\u043e \u043a\u043b\u0438\u043a\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0445 URL.<\/p>\n<p>  \u041a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u0434\u043e\u0433\u0430\u0434\u0430\u043b\u0438\u0441\u044c, \u044f \u0432\u044b\u0431\u0440\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0443\u0442\u044c )<\/p>\n<p>  \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043a\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435, \u0442.\u043a. \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u043a\u043e\u043b\u043e-\u043a\u043d\u043e\u043f\u043e\u0447\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u044f \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b \u0432\u0441\u0435 JS \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0431\u043b\u0430\u0433\u043e \u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442. \u0415\u0441\u043b\u0438 \u043a\u043e\u043c\u0443-\u0442\u043e \u043d\u0443\u0436\u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u0430\u044f \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043c\u043e\u0439, \u0443\u0436\u0435 \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<pre><code>&lt;script src=&quot;https:\/\/cdn.onesignal.com\/sdks\/OneSignalSDK.js&quot; async&gt;&lt;\/script&gt; &lt;script&gt;     var OneSignal = OneSignal || [];     OneSignal.push([&quot;init&quot;, {         appId: &quot;\u043c\u043e\u0439 id \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f&quot;,         subdomainName: 'laravel-news', \/\/\u043c\u043e\u0439 \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d \u043d\u0430 onesignal.com (\u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f)         notifyButton: {             enable: true, \/\/ Set to false to hide,             size: 'large', \/\/ One of 'small', 'medium', or 'large'             theme: 'default', \/\/ One of 'default' (red-white) or 'inverse&quot; (whi-te-red)             position: 'bottom-right', \/\/ Either 'bottom-left' or 'bottom-right'               offset: {             offset: {                 bottom: '90px',                 left: '0px', \/\/ Only applied if bottom-left                 right: '80px' \/\/ Only applied if bottom-right             },             text: {                 &quot;tip.state.unsubscribed&quot;: &quot;\u041f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e \u043d\u043e\u0432\u044b\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043f\u0440\u044f\u043c\u043e \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435&quot;,                 &quot;tip.state.subscribed&quot;: &quot;\u0412\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0430 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f&quot;,                 &quot;tip.state.blocked&quot;: &quot;\u0412\u044b \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f&quot;,                 &quot;message.prenotify&quot;: &quot;\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e \u043d\u043e\u0432\u044b\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445&quot;,                 &quot;message.action.subscribed&quot;: &quot;\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443!&quot;,                 &quot;message.action.resubscribed&quot;: &quot;\u0412\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0430 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f&quot;,                 &quot;message.action.unsubscribed&quot;: &quot;\u0423\u0432\u044b, \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e \u0441\u0430\u043c\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445&quot;,                 &quot;dialog.main.title&quot;: &quot;\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438  \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439&quot;,                 &quot;dialog.main.button.subscribe&quot;: &quot;\u041f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f&quot;,                 &quot;dialog.main.button.unsubscribe&quot;: &quot;\u041f\u043e\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043e\u043f\u0440\u043e\u043c\u0435\u0442\u0447\u0438\u0432\u043e \u0438 \u043e\u0442\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f&quot;,                 &quot;dialog.blocked.title&quot;: &quot;\u0421\u043d\u043e\u0432\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e \u0441\u0430\u043c\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445&quot;,                 &quot;dialog.blocked.message&quot;: &quot;\u0421\u043b\u0435\u0434\u0443\u0439\u0442\u0435 \u044d\u0442\u0438\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f:&quot;             }         },         prenotify: true, \/\/ Show an icon with 1 unread message for first-time site visitors         showCredit: false, \/\/ Hide the OneSignal logo         welcomeNotification: {             &quot;title&quot;: &quot;\u041d\u043e\u0432\u043e\u0441\u0442\u0438 Laravel&quot;,             &quot;message&quot;: &quot;\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443!&quot;         },         promptOptions: {             showCredit: false, \/\/ Hide Powered by OneSignal             actionMessage: &quot;\u043f\u0440\u043e\u0441\u0438\u0442 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f:&quot;,             exampleNotificationTitleDesktop: &quot;\u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435&quot;,             exampleNotificationMessageDesktop: &quot;\u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u0412\u0430\u0448 \u041f\u041a&quot;,             exampleNotificationTitleMobile: &quot; \u041f\u0440\u0438\u043c\u0435\u0440 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f&quot;,             exampleNotificationMessageMobile: &quot;\u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u0412\u0430\u0448\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435&quot;,             exampleNotificationCaption: &quot;(\u043c\u043e\u0436\u043d\u043e  \u043e\u0442\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u0432 \u043b\u044e\u0431\u043e\u0435 \u0432\u0440\u0435\u043c\u044f)&quot;,             acceptButtonText: &quot;\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c&quot;.toUpperCase(),             cancelButtonText: &quot;\u041d\u0435\u0442, \u0441\u043f\u0430\u0441\u0438\u0431\u043e&quot;.toUpperCase()         }      }]); &lt;\/script&gt;<\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430.<\/p>\n<h2>\u0421\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c. \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430.<\/h2>\n<p>  \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c\u0443.<\/p>\n<p>  <strong>\u0417\u0430\u0434\u0430\u0447\u0430: \u043f\u0440\u0438 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u043f\u043e\u0441\u0442\u0430 (\u0441\u0442\u0430\u0442\u044c\u0438) \u0440\u0430\u0437\u043e\u0441\u043b\u0430\u0442\u044c push \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f.<\/strong><\/p>\n<p>  \u041d\u043e, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u0435\u0440\u0436\u0438\u043c \u0432 \u0443\u043c\u0435, \u0447\u0442\u043e \u0441\u043a\u043e\u0440\u043e \u043f\u0440\u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430\u043c 100% \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0449\u0435 \u043d\u0435 \u043e\u0434\u043d\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0441\u043b\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0432 \u00ab\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u043a\u0441\u0442\u044b\u00bb \u044f\u043d\u0434\u0435\u043a\u0441-\u0432\u0435\u0431\u043c\u0430\u0441\u0442\u0435\u0440\u0430, \u0447\u0438\u0440\u0438\u043a\u043d\u0443\u0442\u044c \u0432 \u0442\u0432\u0438\u0442\u0442\u0435\u0440 \u0438 \u0442\u043f.<\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0434\u043e \u0432\u0435\u0441\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043a\u0430\u043a-\u0442\u043e \u0444\u044d\u043d\u0448\u0443\u0439\u043d\u0435\u043d\u044c\u043a\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u0430 \u043d\u0435 \u043f\u0438\u0445\u0430\u0442\u044c \u0432\u0441\u0435 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u043b\u0438, \u0443\u043f\u0430\u0441\u0438\u0431\u043e\u0445, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/laravel-news.ru\/attach\/1a\/7b\/56e41328548fe.jpg\"\/><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0435\u043c. \u0421\u0430\u043c\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u2014 \u044d\u0442\u043e \u0447\u0442\u043e? \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u2013 <strong>\u0441\u043e\u0431\u044b\u0442\u0438\u0435<\/strong>! \u0422\u0430\u043a \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0436\u0435 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/laravel.com\/docs\/5.2\/events\"><strong>\u0441\u043e\u0431\u044b\u0442\u0438\u044f<\/strong><\/a>. \u0418\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u043b\u0430\u0440\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u0430.<\/p>\n<blockquote><p>\u041d\u0443 \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u0440\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0431\u044b\u043b \u0441\u043f\u043e\u0439\u043b\u0435\u0440 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u0441\u0440\u0430\u0437\u0443 \u0434\u043e\u0433\u0430\u0434\u0430\u043b\u0438\u0441\u044c )<\/p><\/blockquote>\n<p>  \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e <a href=\"https:\/\/laravel.com\/docs\/5.2\/events#registering-events-and-listeners\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a> \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0430\u043c\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0443\u0434\u043e\u0431\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435.<\/p>\n<h2>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434<\/h2>\n<p>  \u041c\u044b \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043c \u0442\u0430\u043a: \u0432 app\/Providers\/EventServiceProvider.php \u0443\u043a\u0430\u0436\u0435\u043c \u043d\u0430\u0448\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0438 \u0435\u0433\u043e \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f. \u0421\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0430\u0437\u043e\u0432\u0435\u043c PostPublishedEvent, \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f \u2014 PostActionsListener.<\/p>\n<pre><code>protected $listen = [     'App\\Events\\PostPublishedEvent' =&gt; [         'App\\Listeners\\PostActionsListener',     ], ];<\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0438\u0434\u0435\u043c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <\/p>\n<pre><code>php artisan event:generate<\/code><\/pre>\n<p>  \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043a\u043b\u0430\u0441\u0441\u044b \u0441\u043e\u0431\u044b\u0442\u0438\u044f app\/Events\/PostPublishedEvent.php \u0438 \u0435\u0433\u043e \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f app\/Listeners\/PostActionsListener.php<\/p>\n<p>  \u041e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0432 \u043d\u0435\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043b\u043e\u0433-\u043f\u043e\u0441\u0442\u0430.<\/p>\n<pre><code>public $post;  \/**  * PostPublishedEvent constructor.  * @param Post $post  *\/ public function __construct(Post $post) {     $this-&gt;post = $post; }<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0438 \u0434\u0430\u043b\u0435\u0435 \u043f\u043e \u043a\u043e\u0434\u0443 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b. <\/p>\n<pre><code>use App\\Models\\Post;<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044e app\/Listeners\/PostActionsListener.php<\/p>\n<p>  \u042f \u0435\u0433\u043e \u043e\u0431\u043e\u0437\u0432\u0430\u043b \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a!<br \/>  \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u043b\u043e\u0434\u0438\u0442\u044c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0438\u043f \u0441\u043e\u0431\u044b\u0442\u0438\u044f (\u0434\u0443\u043c\u0430\u044e \u0438\u0445 \u043d\u0435 \u043c\u043d\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442) \u044f \u0440\u0435\u0448\u0438\u043b \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u043e\u0434\u0438\u043d.<br \/>  \u0420\u0430\u0437\u0440\u0443\u043b\u0438\u0432\u0430\u0442\u044c \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0442\u043e\u0433\u043e, \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u0430\u043a\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043f\u0440\u0438\u0448\u0435\u043b. <\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a<\/p>\n<pre><code>\/**  * Handle the event.  *  * @param  Event  $event  * @return void  *\/ public function handle(Event $event) {     if ($event instanceof PostPublishedEvent)     {     \/\/\u0442\u0443\u0442  \u0431\u0443\u0434\u0435\u0442 \u043c\u0430\u0433\u0438\u044f     } }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 PostPublishedEvent \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043f\u043e\u043a\u0430 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438. <\/p>\n<p>  \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0442\u0430\u0442\u044c\u044f \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c 2 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 (\u043f\u043e\u043b\u0435 status) <em>\u0427\u0435\u0440\u043d\u043e\u0432\u0438\u043a \/ \u041e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d<\/em>.<\/p>\n<p>  \u0421\u0442\u0430\u0442\u0443\u0441\u044b \u044f \u043e\u0431\u044b\u0447\u043d\u043e \u0434\u0435\u043b\u0430\u044e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a: <\/p>\n<pre><code>const STATUS_DRAFT = 0; const STATUS_PUBLISHED = 1;<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u043d\u0430 \u00ab\u041e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u00bb \u0438 \u043d\u0430\u0434\u043e \u0440\u0430\u0437\u043e\u0441\u043b\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f. <\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0437\u0430\u0432\u0435\u0434\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043a\u043e\u043b\u043e\u043d\u043a\u0443, \u0444\u043b\u0430\u0433 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u043e\u0441\u0442\u0443 \u0431\u044b\u043b\u0438 \u0440\u0430\u0437\u043e\u0441\u043b\u0430\u043d\u044b.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 notify_status, \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0442\u0430\u043a\u0438\u043c\u0438 \u0436\u0435 \u0447\u0442\u043e \u0438 \u0443 status.<br \/>  \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438: <\/p>\n<pre><code>php artisan make:migration add_noty_status_to_post_table --table=post<\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>public function up() {     Schema::table('post', function (Blueprint $table) {         $table-&gt;tinyInteger('notify_status')-&gt;default(0);     });  }<\/code><\/pre>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 <code>php artisan migrate<\/code><\/p>\n<h2>\u0412\u044b\u0437\u043e\u0432 \u0441\u043e\u0431\u044b\u0442\u0438\u044f<\/h2>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435.<br \/>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0439\u043c\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u041b\u0430\u0440\u0430\u0432\u0435\u043b \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u044b\u0435 <em>(\u043e\u043f\u044f\u0442\u044c \u0436\u0435)<\/em> <a href=\"https:\/\/laravel.com\/docs\/5.2\/eloquent#events\">\u0441\u043e\u0431\u044b\u0442\u0438\u044f<\/a>. <\/p>\n<p>  \u0417\u0430\u0432\u0435\u0434\u0435\u043c \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 Post \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 boot \u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043d\u0435\u0433\u043e \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f<\/p>\n<pre><code>public static function boot() {     static::saving(function($instance)     {         return $instance-&gt;onBeforeSave();     });     parent::boot(); }<\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434 onBeforeSave(), \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445:<\/p>\n<pre><code>protected  function onBeforeSave() {     \/\/\u041c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u0442\u0430\u0442\u0443\u0441 \u0441\u0442\u0430\u0442\u044c\u0438 \u2013 \u0435\u0441\u043b\u0438 \u043e\u043d \u00ab\u041e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u00bb, \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0442\u0430\u0442\u0443\u0441 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043e\u043d \u0435\u0449\u0435 \u043d\u0435 \u00ab\u041e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u00bb     if ($this-&gt;status == self::STATUS_PUBLISHED          &amp;&amp; $this-&gt;notify_status &lt; self::STATUS_PUBLISHED){          \/\/\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u0432 \u00ab\u043e\u043f\u0443\u0431\u0438\u043a\u043e\u0432\u0430\u043d\u00bb         $this-&gt;notify_status = self::STATUS_PUBLISHED;          \/\/\u0438  \u00ab\u0432\u044b\u0441\u0442\u0440\u0435\u043b\u0438\u0432\u0430\u0435\u043c\u00bb \u0441\u043e\u0431\u044b\u0442\u0438\u0435 PostPublishedEvent, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0432 \u043d\u0435\u0433\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441.         \\Event::fire(new PostPublishedEvent($this));      } }<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0422\u0435\u0441\u0442\u044b<\/h2>\n<p>  \u0421\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0441\u0442!<br \/>  \u041d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c: \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438 \u043d\u0443\u0436\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0438 \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0447\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043d\u0430\u0434\u043e (\u0441\u0442\u0430\u0442\u0443\u0441 = \u0447\u0435\u0440\u043d\u043e\u0432\u0438\u043a \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440)<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0447\u0438\u0442\u0430\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u044e <a href=\"http:\/\/laravel-news.ru\/blog\/tutorials\/first-laravel-application-1\">\u041f\u0435\u0440\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Laravel. \u041f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e (\u0427\u0430\u0441\u0442\u044c 1)<\/a>,<br \/>  \u0432\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u0442\u0435 \u043f\u0440\u043e \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0438 \u043a\u0430\u043a \u043e\u043d\u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 Post<br \/>  \u0444\u0430\u0439\u043b database\/factories\/PostFactory.php:<\/p>\n<pre><code>$factory-&gt;define(App\\Models\\Post::class, function (Faker\\Generator $faker) {     return [         'title' =&gt; $faker-&gt;text(100),         'publish_date' =&gt; date('Y-m-d H:i'),         'short_text' =&gt; $faker-&gt;text(300),         'full_text' =&gt; $faker-&gt;realText(1000),         'slug' =&gt; str_random(50),         'status' =&gt; \\App\\Models\\Post::STATUS_PUBLISHED,         'category_id' =&gt; 1     ]; });<\/code><\/pre>\n<p>  \u0418 \u0441\u0430\u043c \u0442\u0435\u0441\u0442 tests\/PostCreateTest.php c \u043e\u0434\u043d\u0438\u043c \u043f\u043e\u043a\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u043c:<\/p>\n<pre><code>class PostCreateTest extends TestCase {     public  function testPublishEvent()     {         \/\/\u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u0447\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \\App\\Events\\PostPublishedEvent         $this -&gt; expectsEvents(\\App\\Events\\PostPublishedEvent::class);          \/\/\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043f\u043e\u0441\u0442\u0430 \u0441 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0432 \u0431\u0434          $post  = factory(App\\Models\\Post::class)-&gt;create();          \/\/\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430 \u043c\u0435\u0441\u0442\u0435 \u043b\u0438 \u043e\u043d         $this -&gt; seeInDatabase('post', ['title' =&gt; $post-&gt;title]);          \/\/\u0437\u0430\u0442\u0435\u043c \u0443\u0434\u0430\u043b\u044f\u0435\u043c         $post -&gt; delete();     }  }<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438: \u043f\u0440\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0441\u0430\u043c\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u043a\u0442 \u0438\u0445 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f<\/p><\/blockquote>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c phpunit. \u0414\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0432\u0441\u0435 \u043e\u0442\u043b\u0438\u0447\u043d\u043e <code>OK (1 test, 1 assertion)<\/code><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442, \u043d\u0430 \u0447\u0435\u0440\u043d\u043e\u0432\u0438\u043a\u0430\u0445 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>public  function testNoPublishEvent() {     $this-&gt;doesntExpectEvents(\\App\\Events\\PostPublishedEvent::class);      \/\/ \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430  \u0441\u0442\u0430\u0442\u044c\u0438 \u2013 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c status.     $post  = factory(App\\Models\\Post::class)-&gt;create(                                             [                                                 'status' =&gt; App\\Models\\Post::STATUS_DRAFT                                              ]);      $this-&gt;seeInDatabase('post', ['title' =&gt; $post-&gt;title]);     $post-&gt;delete(); }<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0433\u043e\u043d\u044f\u0435\u043c phpunit: <code>OK (2 tests, 2 assertions)<\/code><\/p>\n<h2>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 push \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439<\/h2>\n<p>  \u041e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u043f\u0443\u0441\u0442\u044f\u043a\u0438, \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u0443\u0448 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0438\u0441 onesignal.com. <\/p>\n<p>  \u0418\u0434\u0435\u043c \u043d\u0430 \u0441\u0430\u0439\u0442 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438 \u043a\u0443\u0440\u0438\u043c \u043c\u0430\u043d\u0443\u0430\u043b \u043f\u043e <a href=\"https:\/\/documentation.onesignal.com\/docs\/server-api-overview\">REST API<\/a>.<\/p>\n<p>  \u041d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 <a href=\"https:\/\/documentation.onesignal.com\/v2.0\/docs\/notifications-create-notification\">\u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f<\/a>.<\/p>\n<p>  \u0412\u0441\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u044b, \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0435\u0441\u0442\u044c.<br \/>  <img decoding=\"async\" src=\"http:\/\/laravel-news.ru\/attach\/6e\/50\/56e4185aafef1.jpg\"\/><\/p>\n<p>  \u042f \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f curl_* \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u044e \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0439 \u043c\u043d\u0435 \u043f\u0430\u043a\u0435\u0442-\u043e\u0431\u0435\u0440\u0442\u043a\u0443 <a href=\"https:\/\/github.com\/anlutro\/php-curl\">anlutro\/curl<\/a>.<\/p>\n<p>  \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 <code>composer require anlutro\/curl<\/code><\/p>\n<p>  \u0412\u0441\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043e\u0444\u043e\u0440\u043c\u0438\u043c \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0445\u0435\u043d\u0434\u043b\u0435\u0440 app\/Handlers\/OneSignalHandler.php: \u0412\u043e\u0442 \u0435\u0433\u043e \u043a\u043e\u0434 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e. \u0412 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043e\u043f\u0438\u0448\u0443 \u0447\u0442\u043e \u043a \u0447\u0435\u043c\u0443<\/p>\n<pre><code>&lt;?php namespace App\\Handlers;  use anlutro\\cURL\\cURL; use App\\Models\\Post;  class OneSignalHandler {      \/\/\u043f\u0440\u0438\u0437\u043d\u0430\u043a \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438     private $test = false;      \/\/ \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c &quot;\u0431\u043e\u0435\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435&quot;     public function __construct($test=false)     {         $this-&gt;test = $test;     }      \/\/\u041c\u0435\u0442\u043e\u0434 sendNotify \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u0441\u0442\u0430\u0442\u044c\u0438.      public function sendNotify(Post $post)     {          \/\/\u041f\u0440\u043e \u043a\u043e\u043d\u0444\u0438\u0433 \u043d\u0438\u0436\u0435         $config = \\Config::get('onesignal');          \/\/\u0435\u0441\u043b\u0438 app_id \u0432\u043e\u043e\u0431\u0449\u0435 \u0437\u0430\u0434\u0430\u043d,  \u0442\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c         if (!empty($config['app_id'])) {          \/\/C\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043c\u0430\u043d\u0443\u0430\u043b\u0443              $data = array(                 'app_id' =&gt; $config['app_id'],                 'contents' =&gt;                     [                         &quot;en&quot; =&gt; $post-&gt;short_text                      ],                 'headings' =&gt;                     [                         &quot;en&quot; =&gt; $post-&gt;title                     ],                   \/\/(\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0442\u043e\u043b\u044c\u043a\u043e WebPush \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f)                                     'isAnyWeb' =&gt; true,                 'chrome_web_icon' =&gt; $config['icon_url'],                 'firefox_icon' =&gt; $config['icon_url'],                 'url' =&gt; $post-&gt;link              );              \/\/\u0415\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 test  ==  true \u0422\u043e  \u043c\u044b  \u0432 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0431\u044f,               if ($this-&gt;test)             {                 $data['include_player_ids'] = [$config['own_player_id']];             } else {                 \/\/\u0435\u0441\u043b\u0438 \u043d\u0435\u0442 - \u0442\u043e  \u0432\u0441\u0435\u0445.                 $data['included_segments'] =  [&quot;All&quot;];             }              \/\/\u0414\u0430\u0442\u0430 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438! \u041e\u0447\u0435\u043d\u044c \u043a\u0440\u0443\u0442\u043e!             if (strtotime($post-&gt;publish_date) &gt; time()) {                 $data['send_after'] = date(DATE_RFC2822, strtotime($post-&gt;publish_date));                                 $data['delayed_option'] = 'timezone';                 $data['delivery_time_of_day'] = '10:00AM';             }              $curl = new cURL();             $req =  $curl-&gt;newJsonRequest('post',$config['url'], $data)-&gt;setHeader('Authorization', 'Basic '.$config['api_key']);             $result = $req-&gt;send();              \/\/\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0443\u0434\u0430\u0447\u0438, \u043f\u0438\u0448\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0432 \u043b\u043e\u0433.             if ($result-&gt;statusCode &lt;&gt; 200) {                 \\Log::error('Unable to push to Onesignal', ['error' =&gt; $result-&gt;body]);                 return false;             }              $result = json_decode($result-&gt;body);             if ($result-&gt;id)             {                 \/\/\u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u0443\u0434\u0430\u0447\u0435\u043d  - \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043a\u043e\u043b-\u0432\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435\u0439.                 return $result-&gt;recipients;             }          }      } } <\/code><\/pre>\n<p>  <\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438<\/h3>\n<p>  \u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a onesignal \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043a\u043e\u043d\u0444\u0438\u0433<br \/>  config\/onesignal.php<\/p>\n<pre><code>&lt;?php  return [     'app_id' =&gt; env('ONESIGNAL_APP_ID',''),     'api_key' =&gt; env('ONESIGNAL_API_KEY',''),     'url' =&gt; env('ONESIGNAL_URL','https:\/\/onesignal.com\/api\/v1\/notifications'),     'icon_url' =&gt; env('ONESIGNAL_ICON_URL',''),     'own_player_id' =&gt; env('ONESIGNAL_OWN_PLAYER_ID','') ];<\/code><\/pre>\n<p>  \u0421\u0430\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 .env <\/p>\n<pre><code>ONESIGNAL_APP_ID = 256aa8d2\u2026. ONESIGNAL_API_KEY = YWR\u2026.. ONESIGNAL_ICON_URL = http:\/\/laravel-news.ru\/images\/laravel_logo_80.jpg ONESIGNAL_URL = https:\/\/onesignal.com\/api\/v1\/notifications ONESIGNAL_OWN_PLAYER_ID = 830\u2026<\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u0442 &#8216;own_player_id\u2019<br \/>  \u042d\u0442\u043e \u043c\u043e\u0439 ID \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0430 \u0438\u0437 \u0430\u0434\u043c\u0438\u043d\u043a\u0438. \u041d\u0443\u0436\u0435\u043d \u043e\u043d \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0431\u0435. <\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/laravel-news.ru\/attach\/22\/c0\/56e4132856c4a.jpg\"\/><\/p>\n<h2>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>  \u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0433\u043e\u0442\u043e\u0432\u0430 \u2013 \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0435\u0433\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e, \u0442\u043a \u043c\u044b \u0437\u0430\u0434\u0430\u043b\u0438 \u0432\u0435\u0440\u043d\u0443\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e \u0441\u0443\u0442\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043d\u0430\u0448 \u0442\u0435\u0441\u0442 \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code>public  function  testSendOnesignal() {     \/\/\u0412 \u043d\u0435\u043c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0441\u0442\u0430\u0442\u044c\u0438 (\u0431\u0435\u0437 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 \u0431\u0434)     $post  = factory(App\\Models\\Post::class)-&gt;make();      \/\/\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a  \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c test = true         $handler = new \\App\\Handlers\\OneSignalHandler(true);      \/\/\u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443      $result  = $handler-&gt;sendNotify($post);      \/\/\u0414\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c 1, \u0442\u043a \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c  \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0431\u0435.     $this-&gt;assertEquals(1,$result);  }<\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 <code>phpunit<\/code> \u2013 \u0442\u0435\u0441\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0438 \u0432\u044b\u0441\u043a\u0430\u043a\u0438\u0432\u0430\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 (\u0438\u043d\u043e\u0433\u0434\u0430 \u0431\u044b\u0432\u0430\u044e\u0442 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0434\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0438\u043d\u0443\u0442)<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0442\u0435\u0441\u0442 \u043d\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442, \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043b\u043e\u0433 \u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u043e, \u0447\u0442\u043e \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0443<\/p>\n<h2>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043a\u043a\u043e\u0440\u0434<\/h2>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0432 \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f<\/p>\n<pre><code>\/**  * Handle the event.  *  * @param  Event  $event  * @return void  *\/ public function handle(Event $event) {     if ($event instanceof PostPublishedEvent)     {         (new OneSignalHandler())-&gt;sendNotify($event-&gt;post);     } } <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u043a\u0430 \u0432\u0441\u0435, \u043d\u043e \u043d\u0430\u0448 \u043a\u043e\u0434 \u0438\u043c\u0435\u0435\u0442 \u0440\u044f\u0434 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432:<br \/>  1) \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0443 \u043d\u0430\u0441 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438, \u0435\u0441\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u044f\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0442\u044f\u0436\u0435\u043b\u044b\u0435 \u0438 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0434\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u0434\u043e\u0439\u0434\u0435\u0442 \u0438 \u0432\u0441\u0435 \u0443\u043f\u0430\u0434\u0435\u0442.<br \/>  2) \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043c\u044b \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u0435\u0441\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0442\u043a\u0430\u0436\u0435\u0442 \u0432 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435, \u043c\u044b \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0439 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e \u043d\u0435\u0439 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u043c.<\/p>\n<p>  \u0411\u0443\u0434\u0435\u043c \u044d\u0442\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0443\u0440\u043e\u043a\u0430\u0445.                 <\/p>\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\/279385\/\"> https:\/\/habrahabr.ru\/post\/279385\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0412 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043a \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043f\u0435\u0440\u0432\u044b\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u0432 \u043c\u043e\u0435\u043c \u0431\u043b\u043e\u0433\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u043b \u043c\u043d\u0435 \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0438\u0441 &quot;Onesignal&quot; \u041d\u0430 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u043b, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u0437\u0432\u0435\u0440\u044c \u0438 \u0441 \u0447\u0435\u043c \u0435\u0433\u043e \u0435\u0434\u044f\u0442. \u041f\u0440\u043e \u0441\u0430\u043c\u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u044f, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0437\u043d\u0430\u043b, \u043f\u0440\u043e \u0441\u0435\u0440\u0432\u0438\u0441 \u2014 \u043d\u0435\u0442.<br \/>  \u041b\u0435\u0433\u043a\u043e \u043d\u0430\u0433\u0443\u0433\u043b\u0438\u043b \u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0441\u0441\u044b\u043b\u0430\u0442\u044c push \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0430, \u043f\u043e \u0432\u0441\u0435\u043c \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u043c \u0438 \u0434\u0435\u0432\u0430\u0439\u0441\u0430\u043c. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u043c\u0435\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u0443\u044e \u043f\u0430\u043d\u0435\u043b\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\/\u043e\u0442\u0447\u0435\u0442\u043d\u043e\u0441\u0442\u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0438 \u0442\u0434.<br \/>  \u041d\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0443. \u0415\u0441\u0442\u044c \u0438 \u0435\u0433\u043e \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0438\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438, \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043b\u0435\u0433\u043a\u043e \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f. \u0414\u0430 \u0438 \u0440\u0435\u0447\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043e \u0441\u0430\u043c\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435, \u0430 \u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Laravel.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/laravel-news.ru\/attach\/d9\/5e\/56e4357ec3c65.jpg\"\/>  <\/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-276238","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/276238","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=276238"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/276238\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=276238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=276238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=276238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}