Complete the code to send a notification to a user in Laravel.
use App\Notifications\InvoicePaid;
$user->[1](new InvoicePaid($invoice));In Laravel, the notify method is used on the user model to send notifications.
Complete the code to define the notification channels in Laravel.
public function via($notifiable)
{
return [[1]];
}The via method returns an array of channels as strings inside square brackets.
Fix the error in the notification class to send an email notification.
public function toMail($notifiable)
{
return (new MailMessage)
->subject('Invoice Paid')
->[1]('Your invoice has been paid successfully.');
}The line method adds a line of text to the email message in Laravel notifications.
Fill both blanks to store notification data in the database.
public function toDatabase($notifiable)
{
return [
'invoice_id' => [1],
'amount' => [2]
];
}Use $this->invoice->id for the invoice ID and $this->invoice->total for the amount to store in the database notification.
Fill all three blanks to customize the notification's broadcast message.
public function toBroadcast($notifiable)
{
return new BroadcastMessage([
'invoice_id' => [1],
'status' => [2],
'message' => [3]
]);
}Use $this->invoice->id for the invoice ID, $this->invoice->status for the status, and a string message for the broadcast notification.