Spot the bug in the Laravel controller

from Laravel
Laravel 13.30.1 / PHP 8.3.33 intermediate 4 min 1 issue to find

Find the object-authorization bug in this generated controller.

php
<?php

final class OrderController
{
    public function update(Request $request, int $orderId): JsonResponse
    {
        $data = $request->validate([
            'status' => ['required', 'in:cancelled'],
        ]);

        $order = Order::findOrFail($orderId);
        $order->update($data);

        return response()->json($order);
    }
}
Open in playground
Report an error