I am using laravel admin panel. how to send mail after editing?
for example: Mail::to($user->email)->send(new Email());
CodePudding user response:
So there are a few ways you can do this but I recommend the following. First create an event listener for the model you want. So from the photo I am guessing that is the Order model. So create a model observer (docs)
php artisan make:observer OrderObserver --model=Order
After that in your Order model put the followng
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
User::observe(OrderObserver::class);
}
Then create an new notification by following the guide in the docs. And finally in the updated method in your observer put the following
Mail::to(auth()->user()->email)->send(new YourNotification());