Commit 29c6666
committed
fix: use exception instead of response in onBefore callback for duplicate driver check
The previous fix returned response()->error() directly from inside the
createRecordFromRequest onBefore callback. The trait checks for a
JsonResponse return and short-circuits correctly, but the outer
createRecord method then passed the JsonResponse object as $record
into the Driver resource serializer (line 245), causing:
ErrorException: Undefined property: Illuminate\Http\JsonResponse::$id
in DelegatesToResource.php
The correct approach is to throw a \Exception from within the callback,
which propagates out of createRecordFromRequest and is caught by the
existing catch (\Exception $e) block, which then returns
response()->error($e->getMessage()) — producing the correct 400 JSON
error response to the frontend.1 parent fc3548f commit 29c6666
1 file changed
Lines changed: 1 addition & 1 deletion
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| |||
0 commit comments