Mid-Level
November 18, 2026Spot the bug: Laravel
One snippet. Find the bug, or prove there isn't one.
php
1<?php
2
3namespace App\Services;
4
5use App\Models\User;
6use Illuminate\Database\Eloquent\ModelNotFoundException;
7use InvalidArgumentException;
8
9class UserService
10{
11 public function activate(int $userId): void
12 {
13 try {
14 $user = User::findOrFail($userId);
15 $user->activate();
16 } catch (InvalidArgumentException $e) {
17 report($e);
18 }
19 }
20}Click the lines that carry the problem.
Your verdict
One attempt per day. The answer shows up right after.
Keep your streak
Create an account to keep your streak and track your progress.