Get the $request object in Laravel's model events (ex. created, updated etc.)

Viewed 1306

I am using Eloquent's model events to do some actions after model has been created/updated/deleted. I'm refering to these:

class User extends Model 
{

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

        self::created(function($model){
            // ... code here
        });

        self::updated(function($model){
            // ... code here
        });

        self::deleted(function($model){
            // ... code here
        });
    }

}

The question: I need to access the $request object in any of these. Is it possible? The scenario I am trying to do is to insert some values in another database table once the current model has been stored. The values are in the $request. And I don't have access to the controller to do it manually there.

1 Answers
Related