Orta seviye
18 Kasım 2026Hatayı bul: Laravel
Tek bir kod parçası. Hatayı bul ya da hata olmadığını kanıtla.
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}Soruna yol açan satırlara tıkla.
Kararın
Günde bir deneme. Cevap hemen ardından görünür.
Serini koru
Serini korumak ve ilerlemeni takip etmek için hesap oluştur.