我想使用https://github.com/dillingham/nova-button模塊,但在其示例中,它顯示了如何將按鈕與事件一起使用,但僅顯示其偵聽器。我很難理解他如何定義他的密鑰。這是我的聽眾:<?phpnamespace App\Listeners;use App\Events\DeleteProduct;use Illuminate\Contracts\Queue\ShouldQueue;use Illuminate\Queue\InteractsWithQueue;class DeleteProductListener{ /** * Create the event listener. * * @return void */ public function __construct() { // } /** * Handle the event. * * @param DeleteProduct $event * @return void */ public function handle(DeleteProduct $event) { if ($event->key == 'mark-as-confirmed') { $event->resource->status = 1; $event->resource->save(); } }}這是我的新星場:Button::make('Supprimer', 'mark-as-confirmed') ->event('App\Events\DeleteProduct') ->confirm('êtes vous s?r de vouloir supprimer ce produit?') ->loadingText('Suppression...') ->successText('Supprimé!')這是我點擊按鈕時的錯誤:如何正確設置我的密鑰?
1 回答

守候你守候我
TA貢獻1802條經驗 獲得超10個贊
嘗試這個:
在你的班級修改EventServiceProvider
protected $listen = [
? ? '\NovaButton\Events\ButtonClick' => [
? ? ? ? '\App\Listeners\DeleteProductListener'
? ? ]
];
- 1 回答
- 0 關注
- 172 瀏覽
添加回答
舉報
0/150
提交
取消