Update AdminController

This commit is contained in:
Daniel Supernault 2024-10-10 02:22:55 -06:00
parent afc6db143a
commit 0c6e885b6f
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1

View file

@ -246,7 +246,12 @@ class AdminController extends Controller
public function messagesShow(Request $request, $id) public function messagesShow(Request $request, $id)
{ {
$message = Contact::findOrFail($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')); return view('admin.messages.show', compact('message'));
} }
@ -257,7 +262,17 @@ class AdminController extends Controller
'message' => 'required|string|min:1|max:500', '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); $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->response = $request->input('message');
$message->read_at = now(); $message->read_at = now();
$message->responded_at = now(); $message->responded_at = now();
@ -274,8 +289,17 @@ class AdminController extends Controller
'message' => 'required|string|min:1|max:500', '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); return new AdminMessageResponse($message);
} }
@ -286,6 +310,13 @@ class AdminController extends Controller
]); ]);
$id = $request->input('id'); $id = $request->input('id');
$message = Contact::findOrFail($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) { if ($message->read_at) {
return; return;
} }