Typoin the share array - errror, should be error
Inertia JS Flash message not printing on vue component
Hey Folks, I have two flash message save in "HandleInertiaRequest.php" as follow:
public function share(Request $request)
{
return array_merge(parent::share($request), [
'ziggy' => function () use ($request) {
return array_merge((new Ziggy)->toArray(), [
'location' => $request->url(),
]);
},
'flash' => [
'message' => fn () => $request->session()->get('success'),
'errror' => fn () => $request->session()->get('error'),
],
]);
}
Now when a user is successfully added i used the success message and if i got error i use error message. Thing is success message is working fine but error message is not printing. Although i have checked by inspecting vue i'm getting the page/flash/error message successfully. Can you please guide where i'm making mistake ?
Here is the controller code: public function station(Request $request) { $count = DB::table('stations')->where('ChildID', '=', $request->ChildID)- >get(); if (count($count) > 0) { return back()->with([ 'error' => 'Station Record Already Exisits in this station' ]); } else { //Perform db Inert and return back return back()->with([ 'success' => 'Station Record Added' ]); }
?>
Here is the vue code:
<div v-if="$page.props.flash.error" class="alert_error">
{{ $page.props.flash.error }}
</div>
<div v-if="$page.props.flash.message" class="alert">
{{ $page.props.flash.message }}
</div>
Please or to participate in this conversation.