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 : Option 4

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 : Option 2

How can you return a view in Laravel?

1) return view()

2) view()

3) return render()

4) render()

Answer : Option 1

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 : Option 1

What does the `artisan` command do in Laravel?

1) Manage database

2) Manage application

3) Manage routes

4) Manage sessions

Answer : Option 2

How can you generate a unique URL in Laravel?

1) route()

2) url()

3) secure_url()

4) redirect()

Answer : Option 2

What is the purpose of the `AppServiceProvider`?

1) Service container configuration

2) Route registration

3) View loading

4) Middleware registration

Answer : Option 1

How do you define a custom validation rule in Laravel?

1) Validator::extend()

2) extendValidator()

3) addRule()

4) customValidation()

Answer : Option 1

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 : Option 1

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 : Option 1