Learn Laravel MCQs
Prepare Laravel MCQs (Multiple choice Questions) for exam and job interviews.
What does `tinker` provide in Laravel?
1) Database migrations
2) A REPL (Read-Eval-Print Loop)
3) Middleware testing
4) Service creation
Answer : Option 2
What is the purpose of Laravel’s `Gate` facade?
1) Handling API requests
2) Authorization logic
3) Managing queues
4) Routing requests
Answer : Option 2
Which of the following is a Laravel event broadcast driver?
1) Pusher
2) Redis
3) Memcached
4) Kafka
Answer : Option 1
How do you soft delete a record in Laravel?
1) Model::softDelete()
2) Model::delete()
3) Model::forceDelete()
4) Model::destroy()
Answer : Option 2
Which Artisan command lists all registered routes in Laravel?
1) php artisan route:list
2) php artisan list:routes
3) php artisan make:routes
4) php artisan routes
Answer : Option 1
How do you define middleware in Laravel?
1) Route::middleware()
2) Route::use()
3) Route::guard()
4) Route::handler()
Answer : Option 1
Which Blade directive is used for loops in Laravel?
1) @foreach
2) @loop
3) @for
4) @while
Answer : Option 1
What is Laravel Horizon used for?
1) Monitoring queues
2) Managing migrations
3) Handling database seeding
4) Managing API requests
Answer : Option 1
How do you retrieve all records from a table using Eloquent?
1) Model::getAll()
2) Model::find()
3) Model::all()
4) Model::fetch()
Answer : Option 3
Which of the following is used for dependency injection in Laravel?
1) Services
2) Service Container
3) Middleware
4) Guards
Answer : Option 2