Learn Laravel MCQs
Prepare Laravel MCQs (Multiple choice Questions) for exam and job interviews.
What is the default cache driver in Laravel?
1) file
2) database
3) array
4) redis
Answer : file
How can you perform a database query in Laravel?
1) DB::table()
2) DB::query()
3) DB::execute()
4) DB::select()
Answer : DB::table()
Which command is used to generate a new event in Laravel?
1) php artisan make:event
2) php artisan create:event
3) make:event
4) artisan make:event
Answer : php artisan make:event
How do you define a many-to-many relationship in Eloquent?
1) belongsToMany()
2) hasMany()
3) hasOne()
4) manyToMany()
Answer : belongsToMany()
What is the purpose of the `config` folder in Laravel?
1) Application configuration
2) Route configuration
3) View configuration
4) Session configuration
Answer : Application configuration
Which class is used to handle HTTP requests in Laravel?
1) Request
2) Http
3) Response
4) Input
Answer : Request
How do you create a new request class in Laravel?
1) php artisan make:request
2) php artisan new:request
3) make:request
4) artisan create:request
Answer : php artisan make:request
What does `dd()` function do in Laravel?
1) Dump and die
2) Delete data
3) Display data
4) Debug data
Answer : Dump and die
What is Laravel Passport used for?
1) API authentication
2) Web authentication
3) Database migrations
4) Email verification
Answer : API authentication
Which of the following is a command to generate a new resource controller?
1) php artisan make:controller --resource
2) php artisan new:controller --resource
3) make:controller --resource
4) artisan create:controller --resource
Answer : php artisan make:controller --resource