-
app/Events/SiteUpdated.php
Open in GitHubuse App\Models\Site; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; use ProtoneMedia\Splade\Facades\Splade; class SiteUpdated implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; public function __construct(public Site $site) { // } public function broadcastOn(): array { return [ new PrivateChannel('teams.'.$this->site->server->team_id), ]; } public function broadcastWith() { return [ Splade::refreshOnEvent(), ]; } }
-
app/Models/Site.php
Open in GitHubuse App\Events\SiteUpdated; use Illuminate\Database\Eloquent\Model; class Site extends Model { // ... protected $dispatchesEvents = [ 'updated' => SiteUpdated::class, ]; // ... }