diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 7699545..a6ddfe8 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -4,6 +4,8 @@ use App\Models\User; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Validator; +use Symfony\Component\HttpFoundation\Exception\BadRequestException; class UserController extends Controller { @@ -16,6 +18,15 @@ public function index() // GET /user/{id} public function show(string $id) { + // FIXME: is there more shorter + // validation solution + $v = Validator::make(["id" => $id], [ + "id" => 'integer' + ]); + + if ($v->fails()) + throw new BadRequestException(); + $user = User::query()->findOrFail($id); return response($user);