Learn Laravel MCQs

Prepare Laravel MCQs (Multiple choice Questions) for exam and job interviews.

What is the default authentication guard in Laravel?

1) web

2) api

3) guest

4) admin

Answer : web

How do you access configuration values in Laravel?

1) config()

2) Config::get()

3) Config::getValue()

4) getConfig()

Answer : Config::get()

What is the command to create a new middleware group in Laravel?

1) php artisan make:middleware

2) php artisan new:middleware

3) make:middleware

4) artisan create:middleware

Answer : php artisan make:middleware

What is the purpose of the `app.blade.php` file?

1) Define layout

2) Define routes

3) Define configuration

4) Define middleware

Answer : Define layout

How can you access the current user in Laravel?

1) auth()->user()

2) Auth::user()

3) user()

4) currentUser()

Answer : auth()->user()

What is the command to generate a new seeder class in Laravel?

1) php artisan make:seeder

2) artisan create:seeder

3) make:seeder

4) create:seeder

Answer : php artisan make:seeder

How do you validate form requests in Laravel?

1) FormRequest::validate()

2) Request::validate()

3) validate()

4) check()

Answer : Request::validate()

What is the command to create a new job in Laravel?

1) php artisan make:job

2) php artisan new:job

3) make:job

4) artisan create:job

Answer : php artisan make:job

How do you define a one-to-one relationship in Eloquent?

1) hasOne()

2) belongsTo()

3) hasMany()

4) oneToOne()

Answer : hasOne()

What does the `@section` directive do in Blade?

1) Define a section

2) Include a view

3) Display data

4) Define a layout

Answer : Define a section