Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to start Laravel Tinker from the command line.
Laravel
php artisan [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'serve' instead of 'tinker' starts the web server, not the shell.
Using 'migrate' runs database migrations, not the shell.
✗ Incorrect
Use php artisan tinker to open the interactive Tinker shell for Laravel.
2fill in blank
mediumComplete the code to retrieve all records from the User model in Tinker.
Laravel
App\Models\User::[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'find' requires an ID parameter and returns one record.
Using 'first' returns only the first record.
✗ Incorrect
The all() method fetches all records from the User model.
3fill in blank
hardFix the error in the code to find a user by ID 5 in Tinker.
Laravel
App\Models\User::[1](5);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' returns a collection, not a single record.
Using 'all' returns all records, ignoring the ID.
✗ Incorrect
The find() method retrieves a record by its primary key, here ID 5.
4fill in blank
hardFill both blanks to create a new user with name 'Alice' and save it in Tinker.
Laravel
$user = new App\Models\User(); $user->name = '[1]'; $user->[2]();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'create' as a method on the instance instead of 'save'.
Forgetting to call any method to save the user.
✗ Incorrect
Assign the name 'Alice' and call save() to store the new user.
5fill in blank
hardFill all three blanks to update the email of user with ID 3 to 'new@example.com' in Tinker.
Laravel
$user = App\Models\User::[1](3); $user->[2] = '[3]'; $user->save();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'first' instead of 'find' to get user by ID.
Not assigning the new email string correctly.
✗ Incorrect
Find user ID 3, set the email property, then save the changes.