ledgerrz/app/Events/MutationCreated.php
Daan Meijer a1adf1da1c
Some checks failed
linter / quality (push) Failing after 1m3s
tests / ci (8.3) (push) Failing after 48s
tests / ci (8.4) (push) Failing after 1m5s
tests / ci (8.5) (push) Failing after 1m4s
added media, mutation events, agent instructions
2026-06-15 22:30:17 +02:00

46 lines
1.1 KiB
PHP

<?php
namespace App\Events;
use App\Models\Mutation;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class MutationCreated implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
*/
public function __construct(public Mutation $mutation)
{
//
}
/**
* Get the channels the event should broadcast on.
*
* @return array<int, Channel>
*/
public function broadcastOn(): array
{
$chatId = $this->mutation->ledger->dynamic->chat->id;
return [
new PrivateChannel('chats.'.$chatId),
];
}
public function broadcastWith(): array
{
return [
'mutation' => $this->mutation->load('user', 'ledger', 'media'),
'type' => 'created',
];
}
}