Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a new job class using Artisan.
Laravel
php artisan [1] MakeEmailJob Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using make:controller instead of make:job
Using make:model which creates a model, not a job
Using make:migration which creates a database migration
✗ Incorrect
Use make:job to create a new job class in Laravel.
2fill in blank
mediumComplete the code to dispatch a job named SendWelcomeEmail.
Laravel
SendWelcomeEmail::[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Calling handle() directly instead of dispatch()
Using run() or execute() which are not Laravel job dispatch methods
✗ Incorrect
Use dispatch() to send a job to the queue.
3fill in blank
hardFix the error in the job class constructor to accept a User model.
Laravel
public function __construct([1] $user)
{
$this->user = $user;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'user' which is a variable, not a type
Using incorrect class names like UserModel
✗ Incorrect
The constructor parameter should be type-hinted with the model class name User (capitalized).
4fill in blank
hardFill both blanks to define the job's queue connection.
Laravel
public $[1] = '[2]';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing 'queue' property with 'connection'
Using incorrect values like 'emails' for connection
✗ Incorrect
Use public $connection = 'default'; to set the queue connection.
5fill in blank
hardFill the blanks to create a job class with a handle method that logs a message.
Laravel
class LogJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; public function handle() { [1]::info([2]); } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Logger instead of Log facade
Logging incorrect messages or missing quotes
✗ Incorrect
Use Log::info('Job executed successfully'); inside the handle method to log a message.