execute($recipient, $sender); } catch (\Throwable $e) { \Log::error('Inbox instantiation Failed: ', [$e->getMessage()]); abort(500); } return view('dashboards.user.chat') ->with('recipient', $recipient) ->with('chats', $inbox->messages()->latest()->get()); } /** * @throws \Throwable */ public function store( #[CurrentUser] User $sender, User $recipient, SendMessageRequest $request, SendMessageAction $action ) { $action->execute($sender, $recipient, $request->validated()); response()->json(['message' => 'Message sent successfully.']); } }