migrate to gtea from bistbucket
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\RestaurantDelivery\Events;
|
||||
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Modules\RestaurantDelivery\Models\Delivery;
|
||||
|
||||
class DeliveryCreated implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
public readonly Delivery $delivery
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*/
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [
|
||||
new PrivateChannel("restaurant.{$this->delivery->restaurant_id}.deliveries"),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data to broadcast.
|
||||
*/
|
||||
public function broadcastWith(): array
|
||||
{
|
||||
return [
|
||||
'delivery_id' => $this->delivery->id,
|
||||
'tracking_code' => $this->delivery->tracking_code,
|
||||
'restaurant_id' => $this->delivery->restaurant_id,
|
||||
'status' => $this->delivery->status,
|
||||
'pickup_address' => $this->delivery->pickup_address,
|
||||
'drop_address' => $this->delivery->drop_address,
|
||||
'created_at' => $this->delivery->created_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The event's broadcast name.
|
||||
*/
|
||||
public function broadcastAs(): string
|
||||
{
|
||||
return 'delivery.created';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user