Example #1
0
 public function getShortDescription(Request $request)
 {
     //fetching all the receipient ids
     $userId = Auth::user()->email;
     $message = MessageReceipient::where('receipient_ID', $userId)->get();
     $metaIds = array();
     //fetching meta ids and storing in the array
     foreach ($message as $key => $value) {
         $metaIds[] = $value['meta_Id'];
     }
     //getting all the message corresponding to a user
     $message = Message::whereIn('meta_Id', $metaIds)->groupBy('from')->get();
     foreach ($message as $key => $value) {
         //fetching user id on the basis of email
         $email = $value['from'];
         $userName = User::where('email', $email)->pluck('id');
         //converting time into epoch value
         $epoch = strtotime($value['created_at']);
         $value['epoch'] = $epoch;
         //user name on the basis of email
         if ($value['from'] == $userId) {
             //if message is sending by logged in user set "me"
             $value['from'] = "Me";
         } else {
             //if message is sending by other email address then set user name instead of email id
             $value['from'] = UserDetail::where('userid', $userName)->pluck('name');
         }
         //getting user profile picture path
         $profilePic = UserDetail::where('userid', $userName)->pluck('profilePicPath');
         $value['path'] = $profilePic;
     }
     return $message;
 }
Example #2
0
 /**
  * get all read/unread message
  *
  * @return Response
  */
 public function getAllMessage(Request $request)
 {
     ////getting all the receipiant ids on the basis of looged in user
     $userId = Auth::user()->email;
     $messageReceipaient = MessageReceipient::where('receipient_ID', $userId)->get();
     $metaIds = array();
     //storing all the message recepiaent
     foreach ($messageReceipaient as $key => $value) {
         $metaIds[] = $value['meta_Id'];
     }
     //fetching all the message to display
     $messageReceipaientResult = Message::all();
     return $messageReceipaientResult;
 }