Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jaracas's avatar

Observer not firing off events on model update in Laravel 10

I'm trying to get an observer to work on a model, but for some reason it isn't firing at all. My code:

EventServiceProvider.php

    public function boot(): void
    {
        Ticket::observe(\App\Observers\TicketObserver::class);
    }

models/Ticket.php:

class Ticket extends Model {
    use HasFactory, SoftDeletes, HasEvents;

Observers/TicketObserver.php:

<?php

namespace App\Observers;

use App\Models\Ticket;

class TicketObserver
{
    /**
     * Handle the Ticket "updated" event.
     */
    public function updated(Ticket $ticket): void
    {
        \Log::info('Ticket Updated ');
    }

What am I doing wrong? I'm calling

$ticket->update($data);

To update the ticket, but it's not calling the updated method from the observer.

0 likes
7 replies
LaryAI's avatar
Level 58

It looks like the issue might be with the HasEvents trait being used in the Ticket model. This trait is not a part of Laravel's core and might be interfering with the observer functionality.

Try removing the HasEvents trait from the Ticket model and see if the observer starts firing off events on model update.

If you still want to use the HasEvents trait, you can try manually firing off the updated event in the Ticket model's boot method like so:

protected static function boot()
{
    parent::boot();

    static::updated(function ($ticket) {
        event('eloquent.updated: ' . get_class($ticket), $ticket);
    });
}

This should trigger the updated event and allow the observer to handle it.

Also, make sure that the EventServiceProvider is registered in your config/app.php file.

'providers' => [
    // ...
    App\Providers\EventServiceProvider::class,
    // ...
],
jaracas's avatar

I tried removing HasEvents and I made sure the EventServiceProvider was in my app.php config file and ... Nothing

newbie360's avatar

I guess is the observer updated only fired when the model changed

try change somethings in your form and submit

1 like
jaracas's avatar

I appreciate the reply, but I managed to figure it out last night - turns out I was using the wrong route on the edit page. Whoops šŸ˜…

cwhite's avatar

Note, it's better to override the booted method (designed for this purpose), so you don't have to use parent::boot() inside the boot method.

hamza008's avatar

Laravel Events Not work with mass update or create , Same for Observe mass update not trigger the Observer event

Please or to participate in this conversation.