{"id":480083,"date":"2026-05-18T09:02:04","date_gmt":"2026-05-18T09:02:04","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=480083"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=480083","title":{"rendered":"\u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438\u0437 Laravel \u0432 Centrifugo: Events, listeners, queue jobs \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 real-time payload"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>Real-time \u0432 Laravel-\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u044f\u043c\u043e\u0433\u043e HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a Centrifugo \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u042d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443, \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u0438 \u043e\u0448\u0438\u0431\u043a\u0430\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 frontend \u0438 backend. \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438\u0437 Laravel \u0432 Centrifugo \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0438\u043d\u0430\u0447\u0435: Laravel \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, listener \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 queue job, \u0430 job \u0443\u0436\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 payload \u0432 Centrifugo.<\/p>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u0435\u043d \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u0433\u0434\u0435 real-time \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441 \u0437\u0430\u043a\u0430\u0437\u0430\u043c\u0438, \u043f\u043b\u0430\u0442\u0435\u0436\u0430\u043c\u0438, \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f\u043c\u0438, \u0447\u0430\u0442\u0430\u043c\u0438, \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u043f\u0430\u043d\u0435\u043b\u044f\u043c\u0438 \u0438 \u043b\u044e\u0431\u044b\u043c\u0438 \u0441\u0442\u0430\u0442\u0443\u0441\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. Centrifugo \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 WebSocket-\u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043d\u043e Laravel \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0438\u0441\u0442\u0438\u043d\u044b: \u0438\u043c\u0435\u043d\u043d\u043e backend \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043f\u0440\u0430\u0432\u0430, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0440\u0435\u0448\u0430\u0435\u0442, \u043a\u0430\u043a\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432 Laravel: \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Laravel Events \u0438 listeners, \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b queue jobs, \u043f\u043e\u0447\u0435\u043c\u0443\u00a0<code>afterCommit()<\/code>\u00a0\u043a\u0440\u0438\u0442\u0438\u0447\u0435\u043d \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u0430\u043a\u0438\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 payload \u0431\u0435\u0437 \u043f\u043e\u043b\u043d\u043e\u0439 Eloquent-\u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 Centrifugo \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430<\/h3>\n<p>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0432 Laravel \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043f\u0440\u0438\u043d\u044f\u0442\u044c request, \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u043c\u0443 \u0441\u043b\u043e\u044e \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c response. \u041a\u043e\u0433\u0434\u0430 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 Centrifugo, \u043e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0440\u043e\u0432\u043d\u0435\u0439: HTTP, \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443, \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0444\u043e\u0440\u043c\u0430\u0442 real-time \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0438\u043c\u044f \u043a\u0430\u043d\u0430\u043b\u0430 \u0438 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 \u043a WebSocket-\u0441\u0435\u0440\u0432\u0435\u0440\u0443.<\/p>\n<p>\u041d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0431\u0435\u0437\u043e\u0431\u0438\u0434\u043d\u043e:<\/p>\n<pre><code>namespace App\\Http\\Controllers\\Order;use App\\Models\\Order;use Illuminate\\Http\\JsonResponse;use Illuminate\\Http\\Request;use Illuminate\\Support\\Facades\\Http;class PayOrderController{    public function __invoke(Request $request, int $orderId): JsonResponse    {        $order = Order::query()-&gt;findOrFail($orderId);        $order-&gt;update([            'status' =&gt; 'paid',        ]);        Http::withHeaders(headers: [            'Authorization' =&gt; 'apikey ' . config('services.centrifugo.api_key'),        ])-&gt;post(            url: config('services.centrifugo.api_url') . '\/api\/publish',            data: [                'channel' =&gt; '$users:' . $order-&gt;user_id,                'data' =&gt; [                    'type' =&gt; 'order.status.changed',                    'orderId' =&gt; $order-&gt;id,                    'status' =&gt; $order-&gt;status,                ],            ],        )-&gt;throw();        return response()-&gt;json(data: [            'success' =&gt; true,        ]);    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u043e\u0434 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0414\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 Centrifugo \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d, \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 \u0431\u044b\u0441\u0442\u0440\u044b\u0439, \u0444\u043e\u0440\u043c\u0430\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043d\u0435 \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0438 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043a\u0440\u044b\u0442\u044c \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438. \u0422\u043e \u0435\u0441\u0442\u044c, \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u0432\u0441\u0451 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u043e\u0432\u043d\u043e \u0434\u043e production.<\/p>\n<p>\u0423 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432.<\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, HTTP-\u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 Centrifugo. \u0415\u0441\u043b\u0438 real-time \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u0445\u043e\u0442\u044f \u0437\u0430\u043a\u0430\u0437 \u0443\u0436\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0451\u043d \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0437\u043d\u0430\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e: \u0438\u043c\u044f \u043a\u0430\u043d\u0430\u043b\u0430, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 payload, \u0441\u043f\u043e\u0441\u043e\u0431 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 Centrifugo API \u0438 \u0434\u0435\u0442\u0430\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f.<\/p>\n<p>\u0412-\u0442\u0440\u0435\u0442\u044c\u0438\u0445, \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u0415\u0441\u043b\u0438 \u0442\u043e\u0442 \u0436\u0435 \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u043a\u0430\u0437\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043d\u0435 \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u0430 \u0438\u0437 webhook, command handler \u0438\u043b\u0438 \u0444\u043e\u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439:<\/p>\n<pre><code>HTTP request    \u2193Laravel \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435    \u2193Laravel \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f    \u2193Listener \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435    \u2193Queue job \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 Centrifugo<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Laravel Centrifugo \u0434\u043b\u044f \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u0445 real-time \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439.<\/p>\n<h3>Laravel Events: \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0444\u0430\u043a\u0442, \u0430 \u043d\u0435 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442<\/h3>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u043d\u0435 \u0441 WebSocket \u0438 \u043d\u0435 \u0441 Centrifugo API. \u041d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0441 \u0444\u0430\u043a\u0442\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u0437\u0430\u043a\u0430\u0437 \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u0441\u0442\u0430\u0442\u0443\u0441. \u042d\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0430 \u043d\u0435 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435\u00a0<code>OrderStatusChanged<\/code>:<\/p>\n<pre><code>namespace App\\Events;class OrderStatusChanged{    public function __construct(        public readonly int $orderId,        public readonly int $userId,        public readonly string $status,    ) {    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u043e Centrifugo. \u0412 \u043d\u0451\u043c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0438\u043c\u0435\u043d\u0438 \u043a\u0430\u043d\u0430\u043b\u0430, API endpoint, WebSocket-\u043b\u043e\u0433\u0438\u043a\u0438 \u0438\u043b\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438. \u041e\u043d \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u043a\u0442: \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u043a\u0430\u0437\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f.<\/p>\n<p>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0449\u0435 \u0438 \u0447\u0438\u0449\u0435:<\/p>\n<pre><code>namespace App\\Http\\Controllers\\Order;use App\\Events\\OrderStatusChanged;use App\\Models\\Order;use Illuminate\\Http\\JsonResponse;use Illuminate\\Http\\Request;use Illuminate\\Support\\Facades\\DB;class PayOrderController{    public function __invoke(Request $request, int $orderId): JsonResponse    {        DB::transaction(function () use ($orderId): void {            $order = Order::query()-&gt;findOrFail($orderId);            $order-&gt;update([                'status' =&gt; 'paid',            ]);            event(new OrderStatusChanged(                orderId: $order-&gt;id,                userId: $order-&gt;user_id,                status: 'paid',            ));        });        return response()-&gt;json(data: [            'success' =&gt; true,        ]);    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c Laravel-\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0432 action, service, use case \u0438\u043b\u0438 command handler. \u041d\u043e \u0434\u0430\u0436\u0435 \u0432 \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u0438\u0434\u043d\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0435: \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 Centrifugo. \u041e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0431\u0438\u0437\u043d\u0435\u0441-\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e Laravel Events \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u0444\u0430\u043a\u0442 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0440\u0435\u0430\u043a\u0446\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0431\u044b\u0442\u0438\u0435\u00a0<code>OrderStatusChanged<\/code>\u00a0\u043c\u043e\u0436\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c real-time \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 Centrifugo;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c audit log;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c email;<\/p>\n<\/li>\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u043e\u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0430\u043c\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u043c \u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430.<\/p>\n<h3>Listeners: \u043e\u0442\u0434\u0435\u043b\u044f\u0435\u043c \u0440\u0435\u0430\u043a\u0446\u0438\u044e \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u0442 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438<\/h3>\n<p>Listener \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0440\u0435\u0430\u043a\u0446\u0438\u0438 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e real-time \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u041d\u043e \u0434\u0430\u0436\u0435 listener \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0432 \u043c\u0435\u0441\u0442\u043e \u043f\u0440\u044f\u043c\u043e\u0433\u043e HTTP-\u0432\u044b\u0437\u043e\u0432\u0430 \u043a Centrifugo. \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<pre><code>namespace App\\Listeners;use App\\Events\\OrderStatusChanged;use App\\Jobs\\PublishOrderStatusChangedToRealtime;class SendOrderStatusChangedToRealtime{    public function handle(OrderStatusChanged $event): void    {        PublishOrderStatusChangedToRealtime::dispatch(            orderId: $event-&gt;orderId,            userId: $event-&gt;userId,            status: $event-&gt;status,        )-&gt;afterCommit();    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0430\u0436\u043d\u044b \u0434\u0432\u0435 \u0432\u0435\u0449\u0438.<\/p>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u2014 listener \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 Centrifugo API. \u041e\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0448\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435\u00a0<code>OrderStatusChanged<\/code>\u00a0\u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c real-time \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e.<\/p>\n<p>\u0412\u0442\u043e\u0440\u0430\u044f \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f\u00a0<code>afterCommit()<\/code>. \u0414\u043b\u044f real-time Laravel \u044d\u0442\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0430\u0436\u043d\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c. \u0415\u0441\u043b\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0434\u043e \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, frontend \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441\u00a0<code>paid<\/code>, \u0437\u0430\u0442\u0435\u043c frontend \u0441\u0434\u0435\u043b\u0430\u0435\u0442 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441 \u0437\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0437\u0430\u043a\u0430\u0437\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0441\u0442\u0430\u0440\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441\u00a0<code>pending<\/code>. \u042d\u0442\u043e \u043d\u0435 \u00ab\u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u0431\u0430\u0433 \u0444\u0440\u043e\u043d\u0442\u0430\u00bb. \u042d\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430 backend.<\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435: \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435 commit \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. \u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 Centrifugo \u2014 \u044d\u0442\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u044d\u0444\u0444\u0435\u043a\u0442. \u0417\u043d\u0430\u0447\u0438\u0442, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0435\u0451 \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a Laravel \u043d\u0430\u0434\u0451\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<h3>Queue jobs: \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0432 Centrifugo \u0431\u0435\u0437 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/h3>\n<p>\u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 Centrifugo \u2014 \u044d\u0442\u043e \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0432\u044b\u0437\u043e\u0432. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u043c, \u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c\u0441\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0443\u043f\u0430\u0441\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0433\u043e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u0435.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f queue job:<\/p>\n<pre><code>namespace App\\Jobs;use App\\Services\\Realtime\\CentrifugoPublisher;use Illuminate\\Contracts\\Queue\\ShouldQueue;class PublishOrderStatusChangedToRealtime implements ShouldQueue{    public function __construct(        public readonly int $orderId,        public readonly int $userId,        public readonly string $status,    ) {    }    public function handle(CentrifugoPublisher $publisher): void    {        $publisher-&gt;publish(            channel: '$users:' . $this-&gt;userId,            data: [                'type' =&gt; 'order.status.changed',                'orderId' =&gt; $this-&gt;orderId,                'status' =&gt; $this-&gt;status,            ],        );    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 job \u0434\u0435\u043b\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0437\u0430\u0434\u0430\u0447\u0443: \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b Centrifugo. \u041e\u043d \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442 \u0437\u0430\u043a\u0430\u0437, \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 webhook, \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0431\u0438\u0437\u043d\u0435\u0441-\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u043d\u0435 \u0441\u0442\u0440\u043e\u0438\u0442 HTTP response. \u042d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0421\u0435\u0440\u0432\u0438\u0441 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0444\u043e\u0440\u043c\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e:<\/p>\n<pre><code>namespace App\\Services\\Realtime;use Illuminate\\Support\\Facades\\Http;class CentrifugoPublisher{    public function publish(        string $channel,        array $data,    ): void {        Http::withHeaders(headers: [            'Authorization' =&gt; 'apikey ' . config('services.centrifugo.api_key'),        ])-&gt;post(            url: config('services.centrifugo.api_url') . '\/api\/publish',            data: [                'channel' =&gt; $channel,                'data' =&gt; $data,            ],        )-&gt;throw();    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0432 Centrifugo \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u043f\u0440\u044f\u043c\u044b\u0445 HTTP-\u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043f\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0443. \u0415\u0433\u043e \u043f\u0440\u043e\u0449\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c. \u0415\u0441\u043b\u0438 \u0437\u0430\u0432\u0442\u0440\u0430 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c retry, \u043c\u0435\u0442\u0440\u0438\u043a\u0438, tracing, \u0434\u0440\u0443\u0433\u043e\u0439 endpoint \u0438\u043b\u0438 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 SDK, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.<\/p>\n<p>Queue jobs \u0434\u0430\u044e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432:<\/p>\n<ul>\n<li>\n<p>\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u0436\u0434\u0451\u0442 Centrifugo;<\/p>\n<\/li>\n<li>\n<p>\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0435 \u043b\u043e\u043c\u0430\u0435\u0442 \u0431\u0438\u0437\u043d\u0435\u0441-\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0448\u0438\u0431\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e;<\/p>\n<\/li>\n<li>\n<p>real-time \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0441\u043b\u043e\u0435\u043c.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f production-\u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u044d\u0442\u043e \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0435, \u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043d\u0430\u044f \u0433\u0438\u0433\u0438\u0435\u043d\u0430.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443\u00a0afterCommit()\u00a0\u0432\u0430\u0436\u0435\u043d \u0434\u043b\u044f real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/h3>\n<p>\u0414\u043b\u044f real-time \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0432\u0430\u0436\u0435\u043d \u043f\u043e\u0440\u044f\u0434\u043e\u043a. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d\u043e \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u043f\u043b\u0430\u0442\u0435\u0436\u0435\u0439, \u0437\u0430\u043a\u0430\u0437\u043e\u0432, \u0432\u044b\u043f\u043b\u0430\u0442, \u0437\u0430\u044f\u0432\u043e\u043a, \u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>DB::transaction(function () use ($order): void {    $order-&gt;update([        'status' =&gt; 'paid',    ]);    PublishOrderStatusChangedToRealtime::dispatch(        orderId: $order-&gt;id,        userId: $order-&gt;user_id,        status: 'paid',    );});<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0432\u0441\u0451 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u0417\u0430\u043a\u0430\u0437 \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0438, job \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438. \u041d\u043e \u0435\u0441\u043b\u0438 job \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0434\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, frontend \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441.<\/p>\n<p>\u041b\u0443\u0447\u0448\u0435 \u0442\u0430\u043a:<\/p>\n<pre><code>DB::transaction(function () use ($order): void {    $order-&gt;update([        'status' =&gt; 'paid',    ]);    PublishOrderStatusChangedToRealtime::dispatch(        orderId: $order-&gt;id,        userId: $order-&gt;user_id,        status: 'paid',    )-&gt;afterCommit();});<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0449\u0451 \u043b\u0443\u0447\u0448\u0435 \u2014 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c Laravel Event, \u0430 dispatch job \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432 listener \u0447\u0435\u0440\u0435\u0437\u00a0<code>afterCommit()<\/code>. \u0422\u043e\u0433\u0434\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u0444\u0430\u043a\u0442 \u0438 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u0430\u044f \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0430 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b.<\/p>\n<p>\u0426\u0435\u043f\u043e\u0447\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code>\u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u0430\u0441\u044c    \u2193Laravel \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435    \u2193\u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0430\u0441\u044c    \u2193Job \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c    \u2193Job \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0432 Centrifugo    \u2193Frontend \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 real-time \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u043e\u0442\u043a\u0430\u0442\u0438\u043b\u0430\u0441\u044c, real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0435\u0442.<\/p>\n<h3>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 payload: \u043d\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0439\u0442\u0435 Eloquent-\u043c\u043e\u0434\u0435\u043b\u044c \u0432 WebSocket<\/h3>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0447\u0430\u0441\u0442\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432 Centrifugo \u2014 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u043d\u0443\u044e Eloquent-\u043c\u043e\u0434\u0435\u043b\u044c:<\/p>\n<pre><code>$publisher-&gt;publish(    channel: '$users:' . $order-&gt;user_id,    data: $order-&gt;toArray(),);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u043f\u043b\u043e\u0445\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 \u043f\u043e\u043b\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u044b, \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0435 \u0441\u0443\u043c\u043c\u044b, timestamps, \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0440\u0438\u0441\u043a\u0430, \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0438\u043b\u0438 \u0441\u0432\u044f\u0437\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 frontend \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c.<\/p>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, frontend \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b backend-\u043c\u043e\u0434\u0435\u043b\u0438. \u041b\u044e\u0431\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 Eloquent-\u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c WebSocket-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442.<\/p>\n<p>\u0412-\u0442\u0440\u0435\u0442\u044c\u0438\u0445, payload \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0442\u044f\u0436\u0451\u043b\u044b\u043c. Real-time \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u043c \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c, \u0430 \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0430\u043c\u043f \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 payload \u0434\u043b\u044f Centrifugo \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c:<\/p>\n<pre><code>{  \"type\": \"order.status.changed\",  \"orderId\": 7821,  \"status\": \"paid\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f:<\/p>\n<pre><code>{  \"type\": \"notification.created\",  \"notificationId\": 981}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u0447\u0430\u0442\u0435:<\/p>\n<pre><code>{  \"type\": \"chat.message.created\",  \"roomId\": 45,  \"messageId\": 3001}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f:<\/p>\n<pre><code>{  \"type\": \"admin.payment.risk.detected\",  \"paymentId\": 9912,  \"riskLevel\": \"high\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Real-time payload \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438, \u0430 \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 HTTP API. \u0415\u0441\u043b\u0438 frontend \u043d\u0443\u0436\u043d\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441 \u043a Laravel \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<p>\u042d\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u0441\u043b\u0435 reconnect. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0433 \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043d\u043e\u0443\u0442\u0431\u0443\u043a, \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0432\u043a\u043b\u0430\u0434\u043a\u0443 \u043f\u043e\u0437\u0436\u0435 \u0438\u043b\u0438 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u043c\u0435\u0442\u044c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 HTTP, \u0430 WebSocket \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u044b\u0445 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438.<\/p>\n<h3>\u041f\u043e\u043b\u0435\u00a0type\u00a0\u043a\u0430\u043a \u043e\u0441\u043d\u043e\u0432\u0430 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u043c\u0435\u0436\u0434\u0443 Laravel \u0438 frontend<\/h3>\n<p>\u041f\u043e\u043b\u0435\u00a0<code>type<\/code>\u00a0\u043b\u0443\u0447\u0448\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u041e\u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 frontend \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f:<\/p>\n<pre><code>subscription.on('publication', function (context) {    const event = context.data;    if (event.type === 'order.status.changed') {        updateOrderStatus(event.orderId, event.status);    }    if (event.type === 'notification.created') {        loadNotification(event.notificationId);    }});<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0411\u0435\u0437\u00a0<code>type<\/code>\u00a0frontend \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0443\u0433\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u043e \u043d\u0430\u0431\u043e\u0440\u0443 \u043f\u043e\u043b\u0435\u0439. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c\u00a0<code>orderId<\/code>, \u0437\u043d\u0430\u0447\u0438\u0442 \u044d\u0442\u043e \u0437\u0430\u043a\u0430\u0437. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c\u00a0<code>messageId<\/code>, \u0437\u043d\u0430\u0447\u0438\u0442 \u0447\u0430\u0442. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0431\u044b\u0441\u0442\u0440\u043e \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435.<\/p>\n<p>\u0414\u043b\u044f \u043a\u0440\u0443\u043f\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u043e\u0433\u0438\u0439 \u0444\u043e\u0440\u043c\u0430\u0442:<\/p>\n<pre><code>{  \"type\": \"order.status.changed\",  \"id\": \"evt_01\",  \"occurredAt\": \"2026-05-09T12:00:00+00:00\",  \"data\": {    \"orderId\": 7821,    \"status\": \"paid\"  }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430:<\/p>\n<pre><code>{  \"type\": \"order.status.changed\",  \"orderId\": 7821,  \"status\": \"paid\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043d\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b. \u0423 real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442.<\/p>\n<h3>\u0413\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0438 \u0442\u0438\u043f\u044b real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/h3>\n<p>\u0418\u043c\u0435\u043d\u0430 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0438 \u0442\u0438\u043f\u044b \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0437\u043c\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u043f\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0443. \u0415\u0441\u043b\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f\u00a0<code>$users:15<\/code>, \u0432 \u0434\u0440\u0443\u0433\u043e\u043c\u00a0<code>users:15<\/code>, \u0430 \u0432 \u0442\u0440\u0435\u0442\u044c\u0435\u043c\u00a0<code>$user:15<\/code>, \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0442\u0435\u0440\u044f\u0442\u044c\u0441\u044f. \u041f\u0440\u0438\u0447\u0451\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043a\u0430\u043a \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430, \u0430 \u043a\u0430\u043a \u00ab\u0438\u043d\u043e\u0433\u0434\u0430 Centrifugo \u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u00bb. \u041e\u0431\u044b\u0447\u043d\u043e Centrifugo \u0442\u0443\u0442 \u043d\u0438 \u043f\u0440\u0438 \u0447\u0451\u043c. \u041f\u0440\u043e\u0441\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0438 \u0440\u0430\u0437\u044a\u0435\u0445\u0430\u043b\u0438\u0441\u044c.<\/p>\n<p>\u041b\u0443\u0447\u0448\u0435 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code>namespace App\\Services\\Realtime;class RealtimeChannel{    public static function user(int $userId): string    {        return '$users:' . $userId;    }    public static function order(int $orderId): string    {        return '$orders:' . $orderId;    }    public static function adminPayments(): string    {        return '$admin:payments';    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0438\u043f\u044b \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0442\u043e\u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c:<\/p>\n<pre><code>namespace App\\Services\\Realtime;class RealtimeEventType{    public const ORDER_STATUS_CHANGED = 'order.status.changed';    public const NOTIFICATION_CREATED = 'notification.created';    public const CHAT_MESSAGE_CREATED = 'chat.message.created';}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u043e\u0433\u0434\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435:<\/p>\n<pre><code>$publisher-&gt;publish(    channel: RealtimeChannel::user(userId: $this-&gt;userId),    data: [        'type' =&gt; RealtimeEventType::ORDER_STATUS_CHANGED,        'orderId' =&gt; $this-&gt;orderId,        'status' =&gt; $this-&gt;status,    ],);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u043d\u0435 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u0430\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f. \u042d\u0442\u043e \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u0445\u0430\u043e\u0441\u0430. \u0412 real-time \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0438\u043c\u0435\u043d\u0438 \u043a\u0430\u043d\u0430\u043b\u0430 \u0438\u043b\u0438 \u0442\u0438\u043f\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u043e\u0438\u0442\u044c \u0447\u0430\u0441\u043e\u0432 \u043e\u0442\u043b\u0430\u0434\u043a\u0438.<\/p>\n<h3>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0432 Centrifugo<\/h3>\n<p>Centrifugo \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d. \u0421\u0435\u0442\u044c \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0442\u044c \u0441\u0431\u043e\u0439. API key \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c. Endpoint \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443. \u042d\u0442\u043e \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043b\u043e\u043c\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0435\u0441\u043b\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0443\u0436\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e \u0432 Laravel.<\/p>\n<p>\u0414\u043b\u044f queue job \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043f\u044b\u0442\u043e\u043a \u0438 backoff:<\/p>\n<pre><code>namespace App\\Jobs;use App\\Services\\Realtime\\CentrifugoPublisher;use Illuminate\\Contracts\\Queue\\ShouldQueue;class PublishOrderStatusChangedToRealtime implements ShouldQueue{    public int $tries = 3;    public function backoff(): array    {        return [5, 15, 30];    }    public function __construct(        public readonly int $orderId,        public readonly int $userId,        public readonly string $status,    ) {    }    public function handle(CentrifugoPublisher $publisher): void    {        $publisher-&gt;publish(            channel: RealtimeChannel::user(userId: $this-&gt;userId),            data: [                'type' =&gt; RealtimeEventType::ORDER_STATUS_CHANGED,                'orderId' =&gt; $this-&gt;orderId,                'status' =&gt; $this-&gt;status,            ],        );    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u0435 \u0443\u0434\u0430\u043b\u0430\u0441\u044c \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u043f\u043e\u043f\u044b\u0442\u043e\u043a, \u043e\u0448\u0438\u0431\u043a\u0443 \u043d\u0443\u0436\u043d\u043e \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c:<\/p>\n<pre><code>event typechannelorderIduserIdstatusexception classexception message<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c API key, JWT, \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u0442\u043e\u043a\u0435\u043d\u044b \u0438 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 payload. \u041b\u043e\u0433\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043c\u043e\u0433\u0430\u0442\u044c \u0440\u0430\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044e, \u0430 \u043d\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0443\u0442\u0435\u0447\u043a\u043e\u0439.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432\u0430\u0436\u043d\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u0435 \u0438 \u043d\u0435\u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f. \u041d\u0435 \u043a\u0430\u0436\u0434\u043e\u0435 real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043b\u044e\u0431\u043e\u0439 \u0446\u0435\u043d\u043e\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0437\u0430\u043a\u0430\u0437\u0430, frontend \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 HTTP. WebSocket \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043d\u043e \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u043f\u0440\u0430\u0432\u0434\u044b.<\/p>\n<h3>\u0418\u0442\u043e\u0433\u043e\u0432\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438\u0437 Laravel \u0432 Centrifugo<\/h3>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u0430\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438\u043b\u0438 \u0432\u043d\u0435\u0448\u043d\u044f\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435        \u2193Laravel \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430        \u2193Laravel \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445        \u2193Laravel \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f        \u2193Listener \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435        \u2193Queue job \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 commit \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438        \u2193Job \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 payload \u0432 Centrifugo        \u2193Centrifugo \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0430\u043c \u043a\u0430\u043d\u0430\u043b\u0430        \u2193Frontend \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0441\u043b\u043e\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u0432\u043e\u044e \u0447\u0430\u0441\u0442\u044c:<\/p>\n<pre><code>Controller:HTTP-\u0432\u0445\u043e\u0434 \u0438 response.Application\/domain layer:\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.Laravel Event:\u0444\u0438\u043a\u0441\u0430\u0446\u0438\u044f \u0444\u0430\u043a\u0442\u0430.Listener:\u0440\u0435\u0430\u043a\u0446\u0438\u044f \u043d\u0430 \u0444\u0430\u043a\u0442.Queue job:\u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0430.CentrifugoPublisher:\u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0432 Centrifugo API.Centrifugo:WebSocket-\u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0430\u043c.Frontend:\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u0430 \u0441\u0445\u0435\u043c\u0430 \u0434\u043b\u0438\u043d\u043d\u0435\u0435 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u043d\u043e \u043e\u043d\u0430 \u043d\u0430\u0434\u0451\u0436\u043d\u0435\u0435. \u041e\u043d\u0430 \u043b\u0443\u0447\u0448\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u043f\u0440\u043e\u0449\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442\u0441\u044f \u0438 \u043c\u0435\u043d\u044c\u0448\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<h3>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043b\u044f Laravel real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/h3>\n<p>\u0414\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438\u0437 Laravel \u0432 Centrifugo \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b.<\/p>\n<p>\u041d\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c real-time \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432. \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u0434\u0435\u0442\u0430\u043b\u0438 Centrifugo API.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Laravel Events \u0434\u043b\u044f \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u0444\u0430\u043a\u0442\u043e\u0432. \u0421\u043e\u0431\u044b\u0442\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u0430 \u043d\u0435 \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u043e frontend.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c listeners \u0434\u043b\u044f \u0440\u0435\u0430\u043a\u0446\u0438\u0438 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435. Listener \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441.<\/p>\n<p>\u041f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 queue jobs. \u0421\u0435\u0442\u0435\u0432\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 \u043a Centrifugo \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e.<\/p>\n<p>\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c job \u043f\u043e\u0441\u043b\u0435 commit \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. Frontend \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0435\u0449\u0451 \u043d\u0435 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0414\u0435\u043b\u0430\u0442\u044c payload \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c. \u0412 \u0441\u043e\u0431\u044b\u0442\u0438\u0438 \u043d\u0443\u0436\u043d\u044b\u00a0<code>type<\/code>, \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0441\u0442\u0430\u0442\u0443\u0441 \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439. \u041f\u043e\u043b\u043d\u0443\u044e Eloquent-\u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f.<\/p>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0438 \u0442\u0438\u043f\u044b \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e. \u042d\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u0440\u0438\u0441\u043a \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e. \u041e\u0448\u0438\u0431\u043a\u0430 WebSocket-\u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043b\u043e\u043c\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u043e\u0446\u0435\u0441\u0441.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438\u0437 Laravel \u0432 Centrifugo \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0447\u0430\u0441\u0442\u044c\u044e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0439 backend-\u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b, \u0430 \u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c HTTP-\u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. Laravel \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, listener \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, queue job \u043f\u043e\u0441\u043b\u0435 commit \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 payload \u0432 Centrifugo, \u0430 frontend \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 real-time \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 WebSocket.<\/p>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438. Laravel \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0438\u0441\u0442\u0438\u043d\u044b \u0438 \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0435\u043c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438. Centrifugo \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u044b\u043c real-time \u0441\u043b\u043e\u0435\u043c. Frontend \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043d\u043e \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 HTTP API.<\/p>\n<p>\u0414\u043b\u044f Laravel-\u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0441 \u0437\u0430\u043a\u0430\u0437\u0430\u043c\u0438, \u043f\u043b\u0430\u0442\u0435\u0436\u0430\u043c\u0438, \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f\u043c\u0438, \u0447\u0430\u0442\u0430\u043c\u0438 \u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u043f\u0430\u043d\u0435\u043b\u044f\u043c\u0438 \u044d\u0442\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c real-time \u0431\u0435\u0437 \u0440\u0430\u0437\u0440\u0443\u0448\u0435\u043d\u0438\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b. Real-time \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u0441\u043a\u043e\u0440\u044f\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0430 \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c backend \u0432 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u0443\u044e \u0441\u0432\u0430\u043b\u043a\u0443.<\/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\/articles\/1036322\/\">https:\/\/habr.com\/ru\/articles\/1036322\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Real-time \u0432 Laravel-\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u044f\u043c\u043e\u0433\u043e HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a Centrifugo \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u042d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443, \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u0438 \u043e\u0448\u0438\u0431\u043a\u0430\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 frontend \u0438 backend. \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438\u0437 Laravel \u0432 Centrifugo \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0438\u043d\u0430\u0447\u0435: Laravel \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, listener \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 queue job, \u0430 job \u0443\u0436\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 payload \u0432 Centrifugo.\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u0435\u043d \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u0433\u0434\u0435 real-time \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441 \u0437\u0430\u043a\u0430\u0437\u0430\u043c\u0438, \u043f\u043b\u0430\u0442\u0435\u0436\u0430\u043c\u0438, \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f\u043c\u0438, \u0447\u0430\u0442\u0430\u043c\u0438, \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u043f\u0430\u043d\u0435\u043b\u044f\u043c\u0438 \u0438 \u043b\u044e\u0431\u044b\u043c\u0438 \u0441\u0442\u0430\u0442\u0443\u0441\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. Centrifugo \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 WebSocket-\u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043d\u043e Laravel \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0438\u0441\u0442\u0438\u043d\u044b: \u0438\u043c\u0435\u043d\u043d\u043e backend \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043f\u0440\u0430\u0432\u0430, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0440\u0435\u0448\u0430\u0435\u0442, \u043a\u0430\u043a\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e.\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432 Laravel: \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Laravel Events \u0438 listeners, \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b queue jobs, \u043f\u043e\u0447\u0435\u043c\u0443\u00a0afterCommit()\u00a0\u043a\u0440\u0438\u0442\u0438\u0447\u0435\u043d \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u0430\u043a\u0438\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 payload \u0431\u0435\u0437 \u043f\u043e\u043b\u043d\u043e\u0439 Eloquent-\u043c\u043e\u0434\u0435\u043b\u0438.\u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 Centrifugo \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0432 Laravel \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043f\u0440\u0438\u043d\u044f\u0442\u044c request, \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u043c\u0443 \u0441\u043b\u043e\u044e \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c response. \u041a\u043e\u0433\u0434\u0430 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 Centrifugo, \u043e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0440\u043e\u0432\u043d\u0435\u0439: HTTP, \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443, \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0444\u043e\u0440\u043c\u0430\u0442 real-time \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0438\u043c\u044f \u043a\u0430\u043d\u0430\u043b\u0430 \u0438 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 \u043a WebSocket-\u0441\u0435\u0440\u0432\u0435\u0440\u0443.\u041d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0431\u0435\u0437\u043e\u0431\u0438\u0434\u043d\u043e:namespace App\\Http\\Controllers\\Order;use App\\Models\\Order;use Illuminate\\Http\\JsonResponse;use Illuminate\\Http\\Request;use Illuminate\\Support\\Facades\\Http;class PayOrderController{    public function __invoke(Request $request, int $orderId): JsonResponse    {        $order = Order::query()-&gt;findOrFail($orderId);        $order-&gt;update([            &#8216;status&#8217; =&gt; &#8216;paid&#8217;,        ]);        Http::withHeaders(headers: [            &#8216;Authorization&#8217; =&gt; &#8216;apikey &#8216; . config(&#8216;services.centrifugo.api_key&#8217;),        ])-&gt;post(            url: config(&#8216;services.centrifugo.api_url&#8217;) . &#8216;\/api\/publish&#8217;,            data: [                &#8216;channel&#8217; =&gt; &#8216;$users:&#8217; . $order-&gt;user_id,                &#8216;data&#8217; =&gt; [                    &#8216;type&#8217; =&gt; &#8216;order.status.changed&#8217;,                    &#8216;orderId&#8217; =&gt; $order-&gt;id,                    &#8216;status&#8217; =&gt; $order-&gt;status,                ],            ],        )-&gt;throw();        return response()-&gt;json(data: [            &#8216;success&#8217; =&gt; true,        ]);    }}\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u043e\u0434 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0414\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 Centrifugo \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d, \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 \u0431\u044b\u0441\u0442\u0440\u044b\u0439, \u0444\u043e\u0440\u043c\u0430\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043d\u0435 \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0438 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043a\u0440\u044b\u0442\u044c \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438. \u0422\u043e \u0435\u0441\u0442\u044c, \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u0432\u0441\u0451 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u043e\u0432\u043d\u043e \u0434\u043e production.\u0423 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432.\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, HTTP-\u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 Centrifugo. \u0415\u0441\u043b\u0438 real-time \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u0445\u043e\u0442\u044f \u0437\u0430\u043a\u0430\u0437 \u0443\u0436\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0451\u043d \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0437\u043d\u0430\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e: \u0438\u043c\u044f \u043a\u0430\u043d\u0430\u043b\u0430, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 payload, \u0441\u043f\u043e\u0441\u043e\u0431 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 Centrifugo API \u0438 \u0434\u0435\u0442\u0430\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f.\u0412-\u0442\u0440\u0435\u0442\u044c\u0438\u0445, \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u0415\u0441\u043b\u0438 \u0442\u043e\u0442 \u0436\u0435 \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u043a\u0430\u0437\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043d\u0435 \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u0430 \u0438\u0437 webhook, command handler \u0438\u043b\u0438 \u0444\u043e\u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c.\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439:HTTP request    \u2193Laravel \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435    \u2193Laravel \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f    \u2193Listener \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435    \u2193Queue job \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 Centrifugo\u042d\u0442\u043e \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Laravel Centrifugo \u0434\u043b\u044f \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u0445 real-time \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439.Laravel Events: \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0444\u0430\u043a\u0442, \u0430 \u043d\u0435 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u041d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u043d\u0435 \u0441 WebSocket \u0438 \u043d\u0435 \u0441 Centrifugo API. \u041d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0441 \u0444\u0430\u043a\u0442\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u0437\u0430\u043a\u0430\u0437 \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u0441\u0442\u0430\u0442\u0443\u0441. \u042d\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0430 \u043d\u0435 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435.\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435\u00a0OrderStatusChanged:namespace App\\Events;class OrderStatusChanged{    public function __construct(        public readonly int $orderId,        public readonly int $userId,        public readonly string $status,    ) {    }}\u0422\u0430\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u043e Centrifugo. \u0412 \u043d\u0451\u043c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0438\u043c\u0435\u043d\u0438 \u043a\u0430\u043d\u0430\u043b\u0430, API endpoint, WebSocket-\u043b\u043e\u0433\u0438\u043a\u0438 \u0438\u043b\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438. \u041e\u043d \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u043a\u0442: \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u043a\u0430\u0437\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f.\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0449\u0435 \u0438 \u0447\u0438\u0449\u0435:namespace App\\Http\\Controllers\\Order;use App\\Events\\OrderStatusChanged;use App\\Models\\Order;use Illuminate\\Http\\JsonResponse;use Illuminate\\Http\\Request;use Illuminate\\Support\\Facades\\DB;class PayOrderController{    public function __invoke(Request $request, int $orderId): JsonResponse    {        DB::transaction(function () use ($orderId): void {            $order = Order::query()-&gt;findOrFail($orderId);            $order-&gt;update([                &#8216;status&#8217; =&gt; &#8216;paid&#8217;,            ]);            event(new OrderStatusChanged(                orderId: $order-&gt;id,                userId: $order-&gt;user_id,                status: &#8216;paid&#8217;,            ));        });        return response()-&gt;json(data: [            &#8216;success&#8217; =&gt; true,        ]);    }}\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c Laravel-\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0432 action, service, use case \u0438\u043b\u0438 command handler. \u041d\u043e \u0434\u0430\u0436\u0435 \u0432 \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u0438\u0434\u043d\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0435: \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 Centrifugo. \u041e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0431\u0438\u0437\u043d\u0435\u0441-\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e Laravel Events \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u0444\u0430\u043a\u0442 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0440\u0435\u0430\u043a\u0446\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0431\u044b\u0442\u0438\u0435\u00a0OrderStatusChanged\u00a0\u043c\u043e\u0436\u0435\u0442:\u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c real-time \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 Centrifugo;\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c audit log;\u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c email;\u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443;\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u043e\u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441.\u0421\u0430\u043c\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u043c \u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430.Listeners: \u043e\u0442\u0434\u0435\u043b\u044f\u0435\u043c \u0440\u0435\u0430\u043a\u0446\u0438\u044e \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u0442 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438Listener \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0440\u0435\u0430\u043a\u0446\u0438\u0438 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e real-time \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u041d\u043e \u0434\u0430\u0436\u0435 listener \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0432 \u043c\u0435\u0441\u0442\u043e \u043f\u0440\u044f\u043c\u043e\u0433\u043e HTTP-\u0432\u044b\u0437\u043e\u0432\u0430 \u043a Centrifugo. \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.namespace App\\Listeners;use App\\Events\\OrderStatusChanged;use App\\Jobs\\PublishOrderStatusChangedToRealtime;class SendOrderStatusChangedToRealtime{    public function handle(OrderStatusChanged $event): void    {        PublishOrderStatusChangedToRealtime::dispatch(            orderId: $event-&gt;orderId,            userId: $event-&gt;userId,            status: $event-&gt;status,        )-&gt;afterCommit();    }}\u0417\u0434\u0435\u0441\u044c \u0432\u0430\u0436\u043d\u044b \u0434\u0432\u0435 \u0432\u0435\u0449\u0438.\u041f\u0435\u0440\u0432\u0430\u044f \u2014 listener \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 Centrifugo API. \u041e\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0448\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435\u00a0OrderStatusChanged\u00a0\u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c real-time \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e.\u0412\u0442\u043e\u0440\u0430\u044f \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f\u00a0afterCommit(). \u0414\u043b\u044f real-time Laravel \u044d\u0442\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0430\u0436\u043d\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c. \u0415\u0441\u043b\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0434\u043e \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, frontend \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441\u00a0paid, \u0437\u0430\u0442\u0435\u043c frontend \u0441\u0434\u0435\u043b\u0430\u0435\u0442 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441 \u0437\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0437\u0430\u043a\u0430\u0437\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0441\u0442\u0430\u0440\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441\u00a0pending. \u042d\u0442\u043e \u043d\u0435 \u00ab\u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u0431\u0430\u0433 \u0444\u0440\u043e\u043d\u0442\u0430\u00bb. \u042d\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430 backend.\u041f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435: \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435 commit \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. \u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 Centrifugo \u2014 \u044d\u0442\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u044d\u0444\u0444\u0435\u043a\u0442. \u0417\u043d\u0430\u0447\u0438\u0442, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0435\u0451 \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a Laravel \u043d\u0430\u0434\u0451\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.Queue jobs: \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0432 Centrifugo \u0431\u0435\u0437 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u0430\u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 Centrifugo \u2014 \u044d\u0442\u043e \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0432\u044b\u0437\u043e\u0432. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u043c, \u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c\u0441\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0443\u043f\u0430\u0441\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0433\u043e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u0435.\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f queue job:namespace App\\Jobs;use App\\Services\\Realtime\\CentrifugoPublisher;use Illuminate\\Contracts\\Queue\\ShouldQueue;class PublishOrderStatusChangedToRealtime implements ShouldQueue{    public function __construct(        public readonly int $orderId,        public readonly int $userId,        public readonly string $status,    ) {    }    public function handle(CentrifugoPublisher $publisher): void    {        $publisher-&gt;publish(            channel: &#8216;$users:&#8217; . $this-&gt;userId,            data: [                &#8216;type&#8217; =&gt; &#8216;order.status.changed&#8217;,                &#8216;orderId&#8217; =&gt; $this-&gt;orderId,                &#8216;status&#8217; =&gt; $this-&gt;status,            ],        );    }}\u0422\u0430\u043a\u043e\u0439 job \u0434\u0435\u043b\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0437\u0430\u0434\u0430\u0447\u0443: \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b Centrifugo. \u041e\u043d \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442 \u0437\u0430\u043a\u0430\u0437, \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 webhook, \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0431\u0438\u0437\u043d\u0435\u0441-\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u043d\u0435 \u0441\u0442\u0440\u043e\u0438\u0442 HTTP response. \u042d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438.\u0421\u0435\u0440\u0432\u0438\u0441 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0444\u043e\u0440\u043c\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e:namespace App\\Services\\Realtime;use Illuminate\\Support\\Facades\\Http;class CentrifugoPublisher{    public function publish(        string $channel,        array $data,    ): void {        Http::withHeaders(headers: [            &#8216;Authorization&#8217; =&gt; &#8216;apikey &#8216; . config(&#8216;services.centrifugo.api_key&#8217;),        ])-&gt;post(            url: config(&#8216;services.centrifugo.api_url&#8217;) . &#8216;\/api\/publish&#8217;,            data: [                &#8216;channel&#8217; =&gt; $channel,                &#8216;data&#8217; =&gt; $data,            ],        )-&gt;throw();    }}\u041e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0432 Centrifugo \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u043f\u0440\u044f\u043c\u044b\u0445 HTTP-\u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043f\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0443. \u0415\u0433\u043e \u043f\u0440\u043e\u0449\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c. \u0415\u0441\u043b\u0438 \u0437\u0430\u0432\u0442\u0440\u0430 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c retry, \u043c\u0435\u0442\u0440\u0438\u043a\u0438, tracing, \u0434\u0440\u0443\u0433\u043e\u0439 endpoint \u0438\u043b\u0438 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 SDK, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.Queue jobs \u0434\u0430\u044e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432:\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u0436\u0434\u0451\u0442 Centrifugo;\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0435 \u043b\u043e\u043c\u0430\u0435\u0442 \u0431\u0438\u0437\u043d\u0435\u0441-\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435;\u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c;\u043e\u0448\u0438\u0431\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e;real-time \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0441\u043b\u043e\u0435\u043c.\u0414\u043b\u044f production-\u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u044d\u0442\u043e \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0435, \u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043d\u0430\u044f \u0433\u0438\u0433\u0438\u0435\u043d\u0430.\u041f\u043e\u0447\u0435\u043c\u0443\u00a0afterCommit()\u00a0\u0432\u0430\u0436\u0435\u043d \u0434\u043b\u044f real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0439\u0414\u043b\u044f real-time \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0432\u0430\u0436\u0435\u043d&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-480083","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/480083","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=480083"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/480083\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=480083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=480083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=480083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}