в этом случае вы можете использовать наблюдателя в вашей модели или создать его.
class MotorVehicleObserver
{
public function created(Content $content){
//this function will be called every time you insert new data on your database
//your codes about sending the email will come here
}
}
и для добавления этого наблюдателя в вашу модель:
protected static function boot()
{
parent::boot();
self::observe(new MotorVehicleObserver);
}
Или вы можете добавитьНаблюдатель непосредственно к вашей модели, как показано ниже:
protected static function boot()
{
parent::boot();
static::created(function (self $content){
//this function will called every time you insert a new data on your database
//your codes about sending email will come here
});
}
для получения дополнительной информации посетите: События Laravel