Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a new notification class using Artisan.
Laravel
php artisan [1] NotificationName Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'create:notification' instead of 'make:notification'.
Forgetting to include the notification name after the command.
✗ Incorrect
Use make:notification to create a new notification class in Laravel.
2fill in blank
mediumComplete the code to send a notification to a user instance.
Laravel
$user->[1](new InvoicePaidNotification($invoice)); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'notifyAll' which does not exist on the user model.
Using 'sendNotification' which is not a Laravel method.
✗ Incorrect
The notify method sends a notification to the user instance.
3fill in blank
hardFix the error in the notification class to specify the delivery channels.
Laravel
public function [1](mixed $notifiable): array { return ['mail', 'database']; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'send' or 'deliver' which are not valid method names for channels.
Using 'channels' which is not the correct method name.
✗ Incorrect
The via method defines which channels the notification will use.
4fill in blank
hardFill both blanks to return the mail message with a subject and greeting.
Laravel
public function toMail(mixed $notifiable): MailMessage
{
return (new MailMessage)
->subject([1])
->greeting([2]);
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up subject and greeting strings.
Using variables instead of strings.
✗ Incorrect
The subject sets the email subject, and greeting sets the opening line.
5fill in blank
hardFill all three blanks to create a database notification array with an invoice id, amount, and status.
Laravel
public function toDatabase(mixed $notifiable): array
{
return [
'invoice_id' => [1],
'amount' => [2],
'status' => [3]
];
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong property names or missing the $this keyword.
Using 'pending' instead of 'paid' for status.
✗ Incorrect
The database notification stores invoice id and amount from the invoice object, and the status as 'paid'.