Category: Laravel, api

Notifications in Laravel are typically used to notify users in your application. Users do not have to be the App\Models\User model, but can be any model that includes the Notifiable trait. However, sometimes there is no notifiable model involved, and you need to send a notification directly to a given email address, or a list of addresses. When you try to provide an email address to the send method of the Notification facade, like this: You will get the following error message: TypeError : get_class(): Argument #1 ($object) must be of type object, string given Luckily, the Laravel Framework has a solution for this, with on-demand notifications, that can be written like this: As you can see, the notification object MyNotification is used, but without a model that includes the Notifiable trait.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners