Learn Laravel MCQs
Prepare Laravel MCQs (Multiple choice Questions) for exam and job interviews.
How do you define an accessor in Laravel models?
1) get{Attribute}Attribute()
2) access{Attribute}()
3) get{Attribute}()
4) attribute{Attribute}()
Answer : Option 1
Which file contains the database connection configuration in Laravel?
1) .env
2) app.php
3) database.php
4) config.php
Answer : Option 1
Which of the following is used to dispatch jobs in Laravel?
1) Job::dispatch()
2) Queue::send()
3) Queue::push()
4) Job::send()
Answer : Option 1
Which command is used to clear compiled views in Laravel?
1) php artisan view:clear
2) php artisan cache:clear
3) php artisan clear:views
4) php artisan compile:clear
Answer : Option 1
What is Laravel Nova?
1) An administration panel for Laravel applications
2) A package for handling payments
3) A tool for real-time event broadcasting
4) A testing framework
Answer : Option 1
How do you run all outstanding migrations in Laravel?
1) php artisan migrate
2) php artisan db:migrate
3) php artisan run:migrations
4) php artisan make:migration
Answer : Option 1
Which method in Laravel is used to retrieve an old input after form submission?
1) old()
2) previous()
3) getOldInput()
4) requestOld()
Answer : Option 1
What does the `resource()` method define in Laravel routing?
1) A set of CRUD routes for a resource
2) A single GET route
3) A custom API route
4) A view-only route
Answer : Option 1
How do you define a route for a named resource in Laravel?
1) Route::resource()
2) Route::nameResource()
3) Route::crud()
4) Route::apiResource()
Answer : Option 1
Which Laravel service is used for sending emails?
1) Mail
2) Notification
3) EmailService
4) Mailer
Answer : Option 1