/**
  * Return the admin messages view.
  *
  * @return \Illuminate\View\View
  */
 public function getMessages()
 {
     $table = new AdminMessages(Message::query());
     $table->with(['recipient', 'sender']);
     if (mustard_loaded('feedback')) {
         $table->with(['recipient.feedbackReceived', 'sender.feedbackReceived']);
     }
     return view('mustard::admin.messages', ['table' => $table, 'messages' => $table->paginate()]);
 }
 /**
  * Manage message flags.
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postManage(Request $request)
 {
     foreach ($request->input('messages') as $message_id) {
         $message = Message::find($message_id);
         if (is_null($message) || !$request->has('action')) {
             continue;
         }
         switch ($request->input('action')) {
             case 'mark_read':
                 if ($message->read == false) {
                     $message->read = true;
                     $message->save();
                 }
                 break;
             case 'mark_unread':
                 if ($message->read == true) {
                     $message->read = false;
                     $message->save();
                 }
                 break;
             case 'delete':
                 $message->delete();
                 break;
         }
     }
     return redirect()->back();
 }