public function messageSent($request)
 {
     $this->userInfo = $request;
     $message_information = [];
     $message_information['message_from'] = session('active_user_id');
     $message_information['message_to'] = Users::where('email', '=', $this->userInfo->userInfo->input('message_to'))->pluck('id');
     $message_information['message'] = $this->userInfo->userInfo->input('message');
     DB::beginTransaction();
     Message::create($message_information);
     Notification::create(array('msg_from_user_id' => session('active_user_id')));
     DB::commit();
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $active_user = Users::where('email', $request->input('email'))->where('status', '=', 1)->first();
     if (Hash::check($request->input('password'), $active_user['password'])) {
         Session::put('user_active', 1);
         Session::put('active_user_id', $active_user['id']);
     }
     if (session('user_active') == 1) {
         return $next($request);
     } else {
         return view('registration/login')->with(array('msg' => 'Wrong Credentials or User  inactive'));
     }
 }
 public function postSentmessage(Request $request)
 {
     $userExist = Users::where('email', $request->input('message_to'))->count();
     if ($userExist > 0) {
         Event::fire(new MessageControlEvent($request));
         $msg = 'Message Sent!!!';
         Session::put(['msg' => $msg]);
         return redirect('Users/index');
     } else {
         $msg = 'User does not exist!!!';
         Session::put(['msg' => $msg]);
         return redirect('Users/index');
     }
 }