From 0c6e885b6fbbb86169294eb5206bf09abe99adf3 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 10 Oct 2024 02:22:55 -0600 Subject: [PATCH] Update AdminController --- app/Http/Controllers/AdminController.php | 35 ++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index c25e25beb..b769f3c8e 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -246,7 +246,12 @@ class AdminController extends Controller public function messagesShow(Request $request, $id) { $message = Contact::findOrFail($id); - $user = User::whereNull('status')->findOrFail($message->user_id); + $user = User::whereNull('status')->find($message->user_id); + if(!$user) { + $message->read_at = now(); + $message->save(); + return redirect('/i/admin/messages/home')->with('status', 'Redirected from message sent from a deleted account'); + } return view('admin.messages.show', compact('message')); } @@ -257,7 +262,17 @@ class AdminController extends Controller 'message' => 'required|string|min:1|max:500', ]); + if(config('mail.default') === 'log') { + return redirect('/i/admin/messages/home')->with('error', 'Mail driver not configured, please setup before you can sent email.'); + } + $message = Contact::whereNull('responded_at')->findOrFail($id); + $user = User::whereNull('status')->find($message->user_id); + if(!$user) { + $message->read_at = now(); + $message->save(); + return redirect('/i/admin/messages/home')->with('status', 'Redirected from message sent from a deleted account'); + } $message->response = $request->input('message'); $message->read_at = now(); $message->responded_at = now(); @@ -274,8 +289,17 @@ class AdminController extends Controller 'message' => 'required|string|min:1|max:500', ]); - $message = Contact::whereNull('read_at')->findOrFail($id); + if(config('mail.default') === 'log') { + return redirect('/i/admin/messages/home')->with('error', 'Mail driver not configured, please setup before you can sent email.'); + } + $message = Contact::whereNull('read_at')->findOrFail($id); + $user = User::whereNull('status')->find($message->user_id); + if(!$user) { + $message->read_at = now(); + $message->save(); + return redirect('/i/admin/messages/home')->with('error', 'Redirected from message sent from a deleted account'); + } return new AdminMessageResponse($message); } @@ -286,6 +310,13 @@ class AdminController extends Controller ]); $id = $request->input('id'); $message = Contact::findOrFail($id); + + $user = User::whereNull('status')->find($message->user_id); + if(!$user) { + $message->read_at = now(); + $message->save(); + return redirect('/i/admin/messages/home')->with('error', 'Redirected from message sent from a deleted account'); + } if ($message->read_at) { return; }