Convert all 'foo.'.$bar style concatenations to "foo.{$bar}" interpolation
in event broadcast channels (PostCreated, PostDeleted, PostCommentCreated,
PostPlatformStatusUpdated, NotificationCreated) and the related event
tests.
Document the convention in CLAUDE.md so new code follows the pattern.
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Events;
|
|
|
|
use App\Models\PostPlatform;
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Broadcasting\PrivateChannel;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class PostPlatformStatusUpdated implements ShouldBroadcast
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
public function __construct(public PostPlatform $postPlatform) {}
|
|
|
|
public function broadcastAs(): string
|
|
{
|
|
return 'post.platform.status.updated';
|
|
}
|
|
|
|
public function broadcastOn(): array
|
|
{
|
|
return [
|
|
new PrivateChannel("post.{$this->postPlatform->post_id}"),
|
|
new PrivateChannel("workspace.{$this->postPlatform->post->workspace_id}"),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function broadcastWith(): array
|
|
{
|
|
return [
|
|
'post_id' => $this->postPlatform->post_id,
|
|
];
|
|
}
|
|
|
|
public function broadcastQueue(): string
|
|
{
|
|
return 'broadcasts';
|
|
}
|
|
}
|