Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to chain two jobs in Laravel.
Laravel
$job1->[1]([$job2]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using dispatch instead of chain will run jobs independently.
Using batch is for grouping jobs, not chaining.
✗ Incorrect
In Laravel, the chain method is used to run jobs one after another.
2fill in blank
mediumComplete the code to create a batch of jobs in Laravel.
Laravel
Bus::[1]([$job1, $job2])->dispatch(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using chain instead of batch will run jobs sequentially, not in parallel.
Using dispatch alone does not create a batch.
✗ Incorrect
The batch method creates a batch of jobs that run in parallel.
3fill in blank
hardFix the error in the job chaining code by completing the blank.
Laravel
dispatch(new JobOne())->[1]([new JobTwo()]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using batch instead of chain causes jobs to run in parallel, not sequentially.
Calling dispatch again after dispatch causes errors.
✗ Incorrect
The chain method must be used after dispatching the first job to chain the next jobs.
4fill in blank
hardFill both blanks to create a batch with a then callback.
Laravel
Bus::[1]([$job1, $job2])->[2](function () { // All jobs completed })->dispatch();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using chain instead of batch for grouping jobs.
Using queue instead of then for the callback.
✗ Incorrect
Use batch to create the batch and then to add a callback after all jobs finish.
5fill in blank
hardFill all three blanks to create a batch with a catch callback and a name.
Laravel
Bus::[1]([$job1, $job2]) ->[2](function (Batch $batch, Throwable $e) { // Handle failure }) ->name('[3]') ->dispatch();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using chain instead of batch for grouping jobs.
Using then instead of catch for error handling.
Not providing a batch name string.
✗ Incorrect
Use batch to create the batch, catch to handle failures, and name to assign a batch name.