trypost/app/Events/PostDeleted.php
Paulo Castellano 4f3d9ff015 refactor: prefer string interpolation over concatenation for channel names
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.
2026-05-08 19:22:01 -03:00

47 lines
954 B
PHP

<?php
declare(strict_types=1);
namespace App\Events;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
class PostDeleted implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets;
public function __construct(
public string $postId,
public string $workspaceId,
) {}
public function broadcastAs(): string
{
return 'post.deleted';
}
public function broadcastOn(): array
{
return [
new PrivateChannel("workspace.{$this->workspaceId}"),
];
}
/**
* @return array<string, string>
*/
public function broadcastWith(): array
{
return [
'post_id' => $this->postId,
];
}
public function broadcastQueue(): string
{
return 'broadcasts';
}
}