Laravel 10.xのartisanの「session:table」コマンドを解説します。
Description
新しいイベントクラスの作成
Usage
php artisan make:event [-f|--force] [--] <name>
Arguments
引数 | 必須 | 説明 |
---|---|---|
name | 必須 | イベント名 |
Options
オプション | 省略形 | 必須 | 説明 |
---|---|---|---|
force | f | - | イベントが既に存在する場合でもクラスを作成する |
Examples
no options
php artisan make:event FooEvent
INFO Event [app/Events/FooEvent.php] created successfully.
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class FooEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
*/
public function __construct()
{
//
}
/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn(): array
{
return [
new PrivateChannel('channel-name'),
];
}
}
コメント