ImArtur
190
3
Laravel

Observer is not firing.

Posted 1 year ago by ImArtur

I have a Thread Observer to monitor if thread will be deleted. I have created I new observer and added this method.

    public function deleting(Thread $thread)
    {
        $thread->replies()->delete();
    }

I have a delete method on my ThreadController, and it look like this:


    public function destroy(Thread $thread)
    {
        $thread->delete();
    }

I registered it in AppServiceProvider, boot method like this:

        Thread::observe(ThreadObserver::class);

Before the thread is deleted all the replies should be removed from the database. It is not working, method is not firing at al. I also tried to DD both method but DD is never firing.

Please sign in or create an account to participate in this conversation.