Learn Laravel MCQs

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

What is the purpose of the `resources/assets` directory?

1) Store application assets

2) Store views

3) Store controllers

4) Store routes

Answer : Store application assets

How do you define a route with multiple methods in Laravel?

1) Route::match(["get", "post"], "/url", "Controller@method")

2) Route::any("/url", "Controller@method")

3) Route::methods(["get", "post"], "/url", "Controller@method")

4) Route::multi(["get", "post"], "/url", "Controller@method")

Answer : Route::match(["get", "post"], "/url", "Controller@method")

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

1) php artisan make:job

2) artisan create:job

3) make:job

4) create:job

Answer : php artisan make:job

How can you handle form validation in Laravel?

1) Request::validate()

2) Validator::validate()

3) request()->validate()

4) check()

Answer : request()->validate()

What is the purpose of the `database/seeds` directory?

1) Store database seeders

2) Store migrations

3) Store factories

4) Store model classes

Answer : Store database seeders

How do you access the session data in Laravel?

1) session()->get()

2) session()->data()

3) getSession()

4) data()

Answer : session()->get()

What is the command to clear the application cache in Laravel?

1) php artisan cache:clear

2) php artisan clear:cache

3) php artisan clear

4) php artisan cache:flush

Answer : php artisan cache:clear

How do you create a new Artisan command in Laravel?

1) php artisan make:command

2) artisan create:command

3) make:command

4) create:command

Answer : php artisan make:command

What is the purpose of the `storage/app/public` directory in Laravel?

1) Store public files

2) Store logs

3) Store sessions

4) Store database backups

Answer : Store public files

How do you generate a new route with a name in Laravel?

1) Route::get("/url", "Controller@method")->name("route.name")

2) Route::named("/url", "Controller@method", "route.name")

3) Route::url("/url", "Controller@method")->name("route.name")

4) Route::name("/url", "Controller@method")

Answer : Route::get("/url", "Controller@method")->name("route.name")