Learn Laravel MCQs

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

Which command is used to clear cache in Laravel?

1) php artisan cache:clear

2) php artisan cache:flush

3) php artisan cache:remove

4) php artisan cache:delete

Answer : Option 1

Which file is used for defining web routes in Laravel?

1) web.php

2) app.php

3) api.php

4) routes.php

Answer : Option 1

Which of the following is a testing framework integrated with Laravel?

1) Jest

2) PHPUnit

3) Mocha

4) Karma

Answer : Option 2

How do you perform validation in Laravel?

1) Validator::make()

2) Request::validate()

3) Input::validate()

4) Validator::create()

Answer : Option 1

Which method is used to create relationships in Laravel models?

1) hasOne()

2) belongsTo()

3) hasMany()

4) All of the above

Answer : Option 4

Which is a method for seeding data in Laravel?

1) Seeder::run()

2) DatabaseSeeder::seed()

3) DB::table()->insert()

4) DB::runSeeder()

Answer : Option 3

How do you force delete a record using Eloquent?

1) forceDelete()

2) deleteForce()

3) removeForce()

4) destroyForce()

Answer : Option 1

What is Laravel Passport used for?

1) API Authentication

2) Session Management

3) Database Migration

4) Middleware

Answer : Option 1

What is Laravel Echo used for?

1) Broadcasting events

2) Running migrations

3) API requests

4) Seeding databases

Answer : Option 1

Which command is used to generate a new middleware in Laravel?

1) php artisan make:middleware

2) php artisan create:middleware

3) php artisan generate:middleware

4) php artisan new:middleware

Answer : Option 1