I am trying to create a global exception handler for handling the exception for the api routes to catch the missing uri parameter.
routes/api.php
Route::resource('zones', ZoneController::class)->only(['index', 'store', 'edit']);
Route::patch('zones/{zone}', [ZoneController::class, 'update'])->name('zones.update');
As the code says, the zone parameter is required; therefore, if - for some reason - its not available or does not have any value then I am getting the following exception:
{
"message": "The PATCH method is not supported for route api/zones.
Supported methods: GET, HEAD, POST.",
"exception": "Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException",
...
}
I tried following the documentation, but unfortunately it could not solve my problem.
UPDATE:
I am using the PATCH method for updating/modifying an existing record which requires an identifying parameter: zone. If the parameter is available then the request works as expected(the record is updated with the given values) without any error. However, if the parameter is not available(for some reason) the error pops up.


zone/{zone}? Thnaks.