Challenge - 5 Problems
Laravel Beginner Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate1:30remaining
What does this route return?
Consider this Laravel route defined in
routes/web.php. What will the browser display when you visit /hello?Laravel
<?php use Illuminate\Support\Facades\Route; Route::get('/hello', function () { return 'Hello, Laravel!'; });
Attempts:
2 left
💡 Hint
Look at what the route's closure returns directly.
✗ Incorrect
The route returns a plain string, so the browser will display that text exactly.
📝 Syntax
intermediate1:30remaining
Identify the syntax error in this controller method
Look at this Laravel controller method. Which option correctly identifies the syntax error?
Laravel
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; class WelcomeController extends Controller { public function index() { return view('welcome'); } }
Attempts:
2 left
💡 Hint
Check the end of the return statement line.
✗ Incorrect
In PHP, each statement must end with a semicolon. The return statement is missing it.
❓ state_output
advanced2:00remaining
What is the output of this Blade template?
Given this Blade template
resources/views/greeting.blade.php, what will be rendered in the browser?Laravel
@php
$name = 'Alice';
@endphp
<h1>Hello, {{ $name }}!</h1>
@if(strlen($name) > 3)
<p>Welcome to Laravel.</p>
@endifAttempts:
2 left
💡 Hint
Check how Blade outputs variables and evaluates conditions.
✗ Incorrect
Blade replaces {{ $name }} with 'Alice' and includes the paragraph because the name length is greater than 3.
🔧 Debug
advanced2:00remaining
Why does this route cause a 500 error?
This route causes a server error when accessed. What is the cause?
Laravel
<?php use Illuminate\Support\Facades\Route; Route::get('/user/{id}', function ($id) { $user = User::find($id); return view('user.profile', ['user' => $user]); });
Attempts:
2 left
💡 Hint
Check if all classes used are properly imported.
✗ Incorrect
The code uses User::find but does not import the User model, causing a class not found error.
🧠 Conceptual
expert1:30remaining
What happens when you run this Artisan command?
You run
php artisan make:controller ProductController --resource. What does this command do?Attempts:
2 left
💡 Hint
Think about what the --resource flag means in Laravel controllers.
✗ Incorrect
The --resource flag generates a controller with methods like index, create, store, show, edit, update, and destroy.