Okay I found out, I need to add session value to InteriaRequestsMiddleware:
public function share(Request $request): array
{
$isAdmin = Auth::user() instanceof Admin;
//Log::debug(['session' => $request->session()]);
return array_merge(parent::share($request), [
'csrf' => csrf_token(),
//'flash' => ['success' => fn () => $request->session()->get('success')],
'flash' => [
'notification' => session('notification')
],
'auth' => self::share_auth(Auth::user()),
]);
}
And the I can access it using usePage():
const submit = () => {
form.post('/dashboard/users/admins', {
onStart: () => {
feedbackShow.value = false;
},
onSuccess: () => {
form.name = '';
form.email = '';
form.password = '';
console.log(usePage());
console.log(usePage().props);
feedbackLabel.value = 'User sucessfully Added!';
feedbackDesc.value = usePage().props.value.flash.notification;
feedbackShow.value = true;
},
});
}