0
0
Laravelframework~10 mins

Queued notifications in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to send a notification using the queue.

Laravel
$user->notify(new [1](new InvoicePaid($invoice)));
Drag options to blanks, or click blank then click option'
AInvoicePaid
BMailNotification
CQueuedNotification
DNotification
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the notification class name as a string instead of an instance.
Using a wrong notification class.
2fill in blank
medium

Complete the code to make the notification queueable.

Laravel
class InvoicePaid extends Notification implements [1] { }
Drag options to blanks, or click blank then click option'
ADispatchable
BQueueable
CShouldQueue
DInteractsWithQueue
Attempts:
3 left
💡 Hint
Common Mistakes
Using traits instead of interfaces to queue notifications.
Forgetting to implement ShouldQueue.
3fill in blank
hard

Fix the error in the code to dispatch the notification to the queue.

Laravel
Notification::send($users, (new InvoicePaid($invoice))->[1]());
Drag options to blanks, or click blank then click option'
Aqueue
BsendNow
Cdelay
Dnotify
Attempts:
3 left
💡 Hint
Common Mistakes
Using sendNow() which sends immediately without queue.
Calling notify() which is not a method on notification instances.
4fill in blank
hard

Fill both blanks to delay a queued notification by 10 minutes.

Laravel
return (new InvoicePaid($invoice))->[1](now()->addMinutes(10))->[2]();
Drag options to blanks, or click blank then click option'
Adelay
Bqueue
Csend
Dnotify
Attempts:
3 left
💡 Hint
Common Mistakes
Calling send() instead of queue(), which sends immediately.
Not chaining delay() before queue().
5fill in blank
hard

Fill all three blanks to configure a notification to use a specific queue and connection.

Laravel
return (new InvoicePaid($invoice))->onConnection([1])->onQueue([2])->[3]();
Drag options to blanks, or click blank then click option'
A'database'
B'emails'
Cqueue
Dsend
Attempts:
3 left
💡 Hint
Common Mistakes
Using send() instead of queue(), which sends immediately.
Passing connection or queue names without quotes.