0
0
Laravelframework~10 mins

Mail templates 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 mail using a Mailable class.

Laravel
Mail::to($user->email)->[1](new WelcomeMail());
Drag options to blanks, or click blank then click option'
Asend
Bqueue
Clater
Draw
Attempts:
3 left
💡 Hint
Common Mistakes
Using queue instead of send when immediate sending is needed.
Using raw which is for sending raw text mails.
2fill in blank
medium

Complete the code to define the subject of the mail in the Mailable class.

Laravel
public function build()
{
    return $this->view('emails.welcome')->[1]('Welcome to our site');
}
Drag options to blanks, or click blank then click option'
Asubject
Bcc
Cattach
Dfrom
Attempts:
3 left
💡 Hint
Common Mistakes
Using from instead of subject to set the sender address.
Using attach which is for adding files.
3fill in blank
hard

Fix the error in the Blade mail template to display the user's name safely.

Laravel
<p>Hello, [1]</p>
Drag options to blanks, or click blank then click option'
A$user->name()
B{!! $user->name !!}
Cuser.name
D$user->name
Attempts:
3 left
💡 Hint
Common Mistakes
Using {!! !!} which does not escape output and can be unsafe.
Using parentheses which is incorrect for property access.
4fill in blank
hard

Fill both blanks to pass data to the mail view in the Mailable class.

Laravel
public function build()
{
    return $this->view('emails.notification')->with([1] => [2]);
}
Drag options to blanks, or click blank then click option'
A'user'
B$this->user
C'data'
D$this->data
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without quotes as keys.
Passing incorrect property names.
5fill in blank
hard

Fill all three blanks to create a Markdown mail with a custom greeting and action button.

Laravel
public function build()
{
    return $this->markdown('emails.reminder')
        ->[1]('Reminder')
        ->[2]('Hello, please check your tasks.')
        ->[3]('View Tasks', url('/tasks'));
}
Drag options to blanks, or click blank then click option'
Asubject
Bgreeting
Caction
Dline
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing line with greeting or action.
Missing the URL parameter in action.