jeudi 13 décembre 2018

Customizing Method Not Allowed, 404

I'm creating a rest api and often use Model::findOrFail(id), so I made the following exception handler if nothing is found:

if ($exception instanceof ModelNotFoundException)
        {
            return response()->json([
                'message' => 'Record not found',
            ], 404);
        }

But this way, I can't see which record is not found.. is there a way for me to include the model object it was searching for?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire