I created a work around - I added to HandleInertiaRequests.php middleware the following:
'flash' => [
'success' => fn () => $request->session()->get('success'),
'error' => fn () => $request->session()->get('error'),
'warning' => fn () => $request->session()->get('warning'),
'info' => fn () => $request->session()->get('info'),
],
Then in my controller just flash() the message to the session, so it is picked up by the middleware.
public function update(User $user)
{
$attributes = Request::validate([
'name' => 'required',
'email' => ['required', 'email', 'unique:users,email,' . $user->id],
]);
$user->update($attributes);
session()->flash('success', 'User updated successfully');
return redirect()->route('users.show', $user->id);
// These don't work... try to find a fix?
//->withData(['flash' => ['success' => 'User updated successfully']]);
//->with(['flash' => ['success' => 'User created successfully!']]);
}
Please let me know if there is a simpler way, without adding to the inertia middleware.