Skip to content

Commit 7191b01

Browse files
committed
Add error bag support
1 parent 6d42769 commit 7191b01

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Middleware.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,14 @@ public function resolveValidationErrors(Request $request)
147147
return (object) collect($bag->messages())->map(function ($errors) {
148148
return $errors[0];
149149
})->toArray();
150-
})->pipe(function ($bags) {
151-
return $bags->has('default') ? $bags->get('default') : $bags->toArray();
150+
})->pipe(function ($bags) use ($request) {
151+
if ($bags->has('default') && $request->header('x-inertia-error-bag')) {
152+
return [$request->header('x-inertia-error-bag') => $bags->get('default')];
153+
} else if ($bags->has('default')) {
154+
return $bags->get('default');
155+
} else {
156+
return $bags->toArray();
157+
}
152158
});
153159
}
154160
}

0 commit comments

Comments
 (0)