Learn Laravel MCQs
Prepare Laravel MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is a feature of Eloquent?
1) Easy to use
2) Active Record implementation
3) Database migrations
4) All of the above
Answer : All of the above
What is the purpose of the `web.php` file in Laravel?
1) Define API routes
2) Define web routes
3) Define console commands
4) Define event listeners
Answer : Define web routes
How can you return a view in Laravel?
1) return view()
2) view()
3) return render()
4) render()
Answer : return view()
Which command is used to clear the application cache in Laravel?
1) php artisan cache:clear
2) php artisan clear:cache
3) php artisan cache:flush
4) cache:clear
Answer : php artisan cache:clear
What does the `artisan` command do in Laravel?
1) Manage database
2) Manage application
3) Manage routes
4) Manage sessions
Answer : Manage application
How can you generate a unique URL in Laravel?
1) route()
2) url()
3) secure_url()
4) redirect()
Answer : url()
What is the purpose of the `AppServiceProvider`?
1) Service container configuration
2) Route registration
3) View loading
4) Middleware registration
Answer : Service container configuration
How do you define a custom validation rule in Laravel?
1) Validator::extend()
2) extendValidator()
3) addRule()
4) customValidation()
Answer : Validator::extend()
What is the command to create a new model in Laravel?
1) php artisan make:model
2) php artisan new:model
3) make:model
4) artisan create:model
Answer : php artisan make:model
How can you retrieve all records from a database table using Eloquent?
1) Model::all()
2) Model::get()
3) Model::find()
4) Model::retrieve()
Answer : Model::all()