老师这个 5.3里面$events这个能用吗?我定义了怎么不好使呢
这是question_topic模型
class QuestionTopic extends Model
{
protected $table = 'question_topic';
protected $events = [
'deleted' => QuestionTopicDeleteEvent::class,
];
}
这是EventServiceProvider
protected $listen = [
'App\Events\QuestionTopicDeleteEvent' => [
'App\Listeners\QuestionTopicDeleteListener',
],
];
这是QuestionTopicDeleteEvent
public function __construct(QuestionTopic $question_topic)
{
$this->question_topic = $question_topic;
}
这是QuestionTopicDeleteListener
public function handle(QuestionTopicDeleteEvent $event)
{
dump($event->question_topic->toArray());
dd('正在执行删除操作');
}
走不到打印的地方 不知道哪里错了