Support the ongoing development of Laravel.io →
posted 4 years ago
Laravel

errors event/listener - data from event Not appear in Listener Log

where setup this: broadcastOn()     {   return new PrivateChannel????????? if broadcastOn() omitted is ok? I Log in listener the :

        Log::info('Order Shipped with OrderId: ' . $event->order->orderId);  // $event->order->orderId = Not passed to Listener, well? I get: F:\htdocs_xampp\Laravel\code\MyApp\storage\logs\laravel.log :

[2020-09-10 08:46:51] local.INFO: Order Shipped with OrderId:   [2020-09-10 08:48:34] local.INFO: Order Shipped with OrderId:  

return new PrivateChannel('channel-name');

`> php

namespace App\Events;

use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels;

class OrderShipped {     use Dispatchable, InteractsWithSockets, SerializesModels;

    public $order;

    /**      * Create a new event instance.      *      * @param  \App\Order  $order      * @return void      */     public function __construct($order)     {         $this->order = $order;     }

    /**      * Get the channels the event should broadcast on.      *      * @return \Illuminate\Broadcasting\Channel|array      */     public function broadcastOn()     {         return new PrivateChannel('admins');  // return new PrivateChannel('channel-name');     } }

php

namespace App\Http\Controllers;

use App\Events\OrderShipped; use App\Http\Controllers\Controller; use App\Order;

class OrderController extends Controller {     /**      * Ship the given order.      *      * @param  int  $orderId      * @return Response      */     public function ship($id)     {         // $order = Order::findOrFail($orderId);

        $order = new Order($id); // $id replaced with value=1 same

        // Order shipment logic...

        event(new OrderShipped($order));

        return view('welcome-event');     }

`

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.