Learn Laravel MCQs
Prepare Laravel MCQs (Multiple choice Questions) for exam and job interviews.
Which method in Laravel is used to force a redirect to a secure HTTPS URL?
1) secure()
2) urlSecure()
3) forceSSL()
4) redirectSecure()
Answer : Option 2
What does the `hasMany()` method define in Laravel models?
1) A one-to-many relationship
2) A many-to-many relationship
3) A one-to-one relationship
4) A belongs-to relationship
Answer : Option 1
How do you handle API rate-limiting in Laravel?
1) Throttle middleware
2) RateLimit middleware
3) LimitAPI middleware
4) ControlAPI middleware
Answer : Option 2
What is Laravel?
1) A PHP framework
2) A JavaScript library
3) A database
4) A CSS framework
Answer : A PHP framework
Which command is used to create a new Laravel project?
1) laravel new project
2) php artisan create
3) composer create
4) laravel init project
Answer : laravel new project
What is the default session driver in Laravel?
1) file
2) cookie
3) database
4) array
Answer : file
Which file is used to define routes in Laravel?
1) web.php
2) routes.php
3) route.php
4) app.php
Answer : web.php
How do you run migrations in Laravel?
1) php artisan migrate
2) php migrate
3) php artisan db:migrate
4) migrate
Answer : php artisan migrate
What is Eloquent in Laravel?
1) A templating engine
2) A database abstraction layer
3) A routing system
4) A testing framework
Answer : A database abstraction layer
Which method is used to redirect to a route in Laravel?
1) return redirect()
2) redirect()
3) route()
4) back()
Answer : return redirect()