Ejemplo n.º 1
0
 public function refresh()
 {
     $count = Message::where('id_receive', \Auth::user()->id)->where('read', NULL)->count();
     if ($count) {
         return $count;
     }
 }
 /**
  * Despliega el listado de mensajes nuevos
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     /* Selecciona los mensajes que no han sido vistos del mas reciente al mas antiguo*/
     $messages = Message::where('seen', '=', 'false')->latest()->get();
     /* retorna vista con los mensajes que no han sido vistos */
     return view('adminmessages.index')->with('messages', $messages);
 }
 public function getConversation($id)
 {
     $_messages = Message::where(['conversation_id' => $id])->orderBy('updated_at', 'desc')->get();
     $_conversation = Conversation::find($id);
     $messages = collect();
     foreach ($_messages as $_message) {
         $sender = User::find($_message->author_id);
         $message = array();
         $message['author_id'] = $_message->author_id;
         $message['body'] = $_message->body;
         $message['author_name'] = $sender->name;
         $message['author_surname'] = $sender->surname;
         $message['timestamp'] = $sender->updated_at;
         $messages->push($message);
     }
     $conversation_name = "";
     if ($_conversation->title == "") {
         $conversation_name = ConversationsController::getUsersString($id);
         $_conversation->save();
     } else {
         $conversation_name = $_conversation->title;
     }
     $user = User::find(Auth::id());
     $unreadNotifications = $user->notifications()->unread()->get()->count();
     $notifications = $user->notifications()->get();
     return view('conversations.conversation')->with(['messages' => $messages, 'conversation_name' => $conversation_name, 'id' => $id, 'new_notifications_count' => $user->notifications()->unread()->not_type('message')->get()->count(), 'notifications' => $user->notifications()->not_type('message')->get(), 'new_messagesNotifications_count' => $user->notifications()->unread()->type('message')->get()->count(), 'messagesNotifications' => $user->notifications()->type('message')->get()]);
 }
Ejemplo n.º 4
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (!Auth::check()) {
         return Redirect::to('/login');
     }
     $messages = Message::where('receiver_id', Auth::user()->id)->orderBy('created_at', 'desc')->get();
     return view('inbox', ['messages' => $messages]);
 }
Ejemplo n.º 5
0
 public function show(Request $request, $user)
 {
     $messages = Message::where(['from' => Auth::user()->id, 'to' => $user])->orWhere(['to' => Auth::user()->id, 'from' => $user])->orderBy('id', 'DESC')->paginate(30);
     $messages = $this->sortMessages($messages);
     $data['messages'] = $messages;
     $data['receiver'] = $user;
     return view('messages.show', $data);
 }
Ejemplo n.º 6
0
 public function show($id)
 {
     (new Message())->readOpenMessage($id);
     $messages = Message::where('dialog_id', $id)->orderBy('created_at', 'desc')->get();
     $user_id = Dialog::where('total', $id)->where('user_id', '!=', \Auth::user()->id)->first()->user_id;
     $sender = User::find($user_id);
     return view('show', ['messages' => $messages, 'sender' => $sender, 'id' => $id]);
 }
 /**
  * Despliega la interfaz para el dashboard
  *
  * @return \Illuminate\Http\Response
  */
 public function dashboard()
 {
     /* Selecciona todos los mensajes de la tabla messages que no han sido vistos */
     $newMgs = Message::where('seen', '=', 'false')->get();
     /* Obtiene el número de mensajes que no han sido vistos */
     $quantity = count($newMgs);
     /* retorno la vista del dashboard, con el número de mensajes nuevos */
     return view('pages.dashboard')->with('quantity', $quantity);
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function getSend(User $user)
 {
     $this->authorize('sendMessage', $user);
     $readMessages = Message::where('receiver_id', \Auth::user()->id)->where('user_id', $user->id)->where('type', false)->orderBy('created_at', 'desc')->get();
     foreach ($readMessages as $message) {
         $message->is_read = true;
         $message->save();
     }
     $messages = Message::where('receiver_id', \Auth::user()->id)->where('user_id', $user->id)->where('type', false)->orderBy('created_at', 'desc')->paginate(3);
     return view('message.send', compact('user', 'messages'));
 }
 public function searchTickets()
 {
     //str replace to fix an edge case - a user wants to search for a literal %
     $query = str_replace('%', '\\%', Input::get('query'));
     //collect tickets from various places matched by the search
     $tickets = Ticket::where('subject', 'like', "%{$query}%")->get()->merge(Message::where('text', 'like', "%{$query}%")->get()->map(function ($message) {
         return $message->ticket;
     }))->unique()->filter(function ($ticket) {
         return Gate::allows('view-ticket', $ticket);
     });
     return view("helpdesk/searchResults", compact('tickets'));
 }
Ejemplo n.º 10
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // get all the message for this user
     $logged_user_id = Auth::user()->id;
     $messages = Message::where('receiver_user_id', $logged_user_id)->get();
     $query = "SELECT m.id, m.sender_user_id, m.receiver_user_id, m.message_content, m.created_at, u.name ";
     $query .= "FROM message m, users u ";
     $query .= "WHERE receiver_user_id = " . $logged_user_id . " and u.id = m.sender_user_id ";
     $query .= "ORDER BY created_at DESC ";
     $messages = DB::select(DB::raw($query));
     // load the view and pass the jobs
     return View::make('messaging.index')->with('messages', $messages);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $book = Book::findorFail($id);
     $message = Message::where('book_id', '=', $id)->take(10)->get();
     if (!Auth::check()) {
         $user_id = 1;
     } else {
         $user_id = Auth::user()->id;
     }
     if (is_null($book)) {
         abort(404);
     }
     return view('books.show', compact('book', 'user_id', 'message'));
 }
 /**
  * Add/Edit the message.
  * 
  * @param number $id
  * @return number
  */
 public function save($id)
 {
     $person = Request::input('person');
     $text = Request::input('message');
     if ($id == 0) {
         $message = new Message();
         $message->person = $person;
         $message->message = $text;
         return (int) $message->save();
     } else {
         return (int) Message::where('id', $id)->update(array('message' => $text));
     }
     return 0;
 }
Ejemplo n.º 13
0
 private function hasNewMessages()
 {
     $messages = Message::where(['to' => Auth::user()->id, 'read' => 0])->get();
     if ($messages->count() <= 0) {
         return false;
     } else {
         foreach ($messages as $message) {
             $message->update(['read' => 1]);
             $u = $message->user()->first();
             $avatar = $u->getProfilePictureUrl();
             $data[] = array_merge($message->toArray(), ['user' => $u->toArray(), 'xhr' => route('message', $u['id']), 'avatar_url' => $avatar]);
         }
         $this->messages = $data;
         return true;
     }
 }
Ejemplo n.º 14
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     \Carbon\Carbon::setLocale('zh');
     //默认'en'
     View()->composer('*', function ($view) {
         $navMessages = Message::where(['isread' => 0])->get();
         $type0 = Message::where(['isread' => 0, 'type' => 0])->count();
         $type1 = Message::where(['isread' => 0, 'type' => 1])->count();
         $type2 = Message::where(['isread' => 0, 'type' => 2])->count();
         $type3 = Message::where(['isread' => 0, 'type' => 3])->count();
         view()->share('navMessages', $navMessages);
         view()->share('type0', $type0);
         view()->share('type1', $type1);
         view()->share('type2', $type2);
         view()->share('type3', $type3);
     });
 }
Ejemplo n.º 15
0
 public function __construct()
 {
     /*Licznik zmian, który zmienia się po 24h od dodania zmiany*/
     $date = Carbon::now();
     $date->modify('-24 hours');
     $formatted_date = $date->format('Y-m-d H:i:s');
     $countchange = Change::where('created_at', '>', $formatted_date)->count();
     /*Licznik graczy Online na serwerze*/
     $countonline = Player::where('online', '=', 1)->count();
     /*Licznik niedoczytanych wiadomości prywatnych*/
     $notread1 = Message::where('to_user_id', \Auth::id())->where('read', 0)->count();
     if (\Auth::check()) {
         Cache::remember('users', 5, function () {
             return User::where('id', \Auth::id())->update(['last_activity' => Carbon::now()]);
         });
     }
     /*Licznik i skrypt usuwający i nadający banicję za 4 ostrzeżenia na stronie*/
     $countcautions = Caution::where('user_id', \Auth::id())->count();
     if (!\Auth::guest() && $countcautions == 4) {
         $user = User::where('id', \Auth::id())->first();
         $g = array(4);
         $user->update(['banned' => 'Zbanowany za 4 ostrzeżenia na stronie']);
         $user->group()->sync($g);
     }
     $deleteCaution = Caution::where('user_id', \Auth::id())->where('created_at', '<=', Carbon::now()->subDays(14));
     $deleteCaution->delete();
     $section = Section::lists('name', 'id');
     $lives = Live::latest('created_at')->take(5)->get();
     if (!\Auth::guest()) {
         $notifications = \Auth::user()->notification()->latest('created_at')->take(10)->get();
         View::share('notifications', $notifications);
     }
     View::share('countchange', $countchange);
     View::share('countonline', $countonline);
     View::share('notread1', $notread1);
     View::share('section', $section);
     View::share('lives', $lives);
     $this->middleware('banned', ['except' => ['auth']]);
 }
Ejemplo n.º 16
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('articles', function ($slug) {
         return \Route::currentRouteName() == "articles.edit" ? \App\Article::findOrFail($slug) : \App\Article::published()->findOrFail($slug);
     });
     $router->bind('news', function ($id) {
         return \Route::currentRouteName() == "news.edit" ? \App\News::findOrFail($id) : \App\News::published()->findOrFail($id);
     });
     $router->bind('tags', function ($name) {
         return \App\Tag::where('name', $name)->firstOrFail();
     });
     $router->bind('users', function ($id) {
         return \App\User::where('id', $id)->firstOrFail();
     });
     $router->bind('messages', function ($id) {
         return \App\Message::where('id', $id)->firstOrFail();
     });
     $router->bind('registrants', function ($id) {
         return \App\Registrant::where('id', $id)->firstOrFail();
     });
     $router->model('image', Image::class);
 }
Ejemplo n.º 17
0
 public function GetLastMessages($nb = -1, $idPrevious = 0)
 {
     if ($nb <= 0) {
         if ($idPrevious > 0) {
             $messages = Message::where('id', '<', $idPrevious)->orderBy('id', 'desc')->get();
         } else {
             $messages = Message::orderBy('id', 'desc')->get();
         }
     } else {
         if ($idPrevious > 0) {
             $messages = Message::where('id', '<', $idPrevious)->orderBy('id', 'desc')->take($nb)->get();
         } else {
             $messages = Message::orderBy('id', 'desc')->take($nb)->get();
         }
     }
     $last = true;
     if (count($messages) > 0) {
         $lol = $messages[count($messages) - 1];
         if (Message::where('id', '<', $lol->id)->count() > 0) {
             $last = false;
         }
     }
     return view('front.minichat.messages', array('messages' => $messages, 'isLast' => $last));
 }
Ejemplo n.º 18
0
 public function delMessage(Request $request)
 {
     $r = Message::where('id', $request->get('id'))->delete();
     if ($r) {
         $this->succeed(true);
     } else {
         $this->fail(true);
     }
 }
 /**
  *  Return a list of messages that have been accepted
  *
  */
 public function acceptedMessages(Request $request)
 {
     $per_page = $request->has('per_page') ? $request->get('per_page') : 10;
     $before_time = $request->has('before') ? $request->get('before') : Carbon::now()->format('Y-m-d H:i:s');
     $messages = Message::where('accepted', 1)->where('created_at', '<', $before_time)->orderBy('created_at', 'desc')->simplePaginate($per_page);
     $messages->appends(['per_page' => $per_page]);
     return response()->json(["data" => $messages]);
 }
Ejemplo n.º 20
0
 public function sent()
 {
     $sentMessages = Message::where('sender', \Auth::user()->id)->get();
     $dataView = ['sentMessages' => $sentMessages];
     return view('mr.inbox.sent', $dataView);
 }
Ejemplo n.º 21
0
 /**
  * Collection of all message either send or received by this user
  *
  * @return mixed
  */
 public function allMessages()
 {
     return Message::where('sender_id', $this->id)->orWhere('receiver_id', $this->id);
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     if (\Schema::hasTable('positions')) {
         $positions = Position::all();
         $selectPositions = array();
         $selectPositions[0] = "Select / All";
         foreach ($positions as $position) {
             $selectPositions[$position->slug] = $position->name;
         }
         \View::share('selectPositions', $selectPositions);
     }
     if (\Schema::hasTable('cases_priorities')) {
         $priorities = CasePriority::all();
         $selectPriorities = array();
         $selectPriorities[0] = "Select / All";
         foreach ($priorities as $priority) {
             $selectPriorities[$priority->slug] = $priority->name;
         }
         \View::share('selectPriorities', $selectPriorities);
     }
     if (\Schema::hasTable('titles')) {
         $titles = Title::all();
         $selectTitles = array();
         $selectTitles[0] = "Select / All";
         foreach ($titles as $title) {
             $selectTitles[$title->slug] = $title->name;
         }
         \View::share('selectTitles', $selectTitles);
     }
     if (\Schema::hasTable('languages')) {
         $languages = Language::all();
         $selectLanguages = array();
         $selectLanguages[0] = "Select / All";
         foreach ($languages as $language) {
             $selectLanguages[$language->slug] = $language->name;
         }
         \View::share('selectLanguages', $selectLanguages);
     }
     if (\Schema::hasTable('departments')) {
         $departments = Department::all();
         $selectDepartments = array();
         $selectDepartments[0] = "Select / All";
         foreach ($departments as $department) {
             $selectDepartments[$department->slug] = $department->name;
         }
         \View::share('selectDepartments', $selectDepartments);
     }
     if (\Schema::hasTable('users_roles')) {
         $roles = UserRole::all();
         $selectRoles = array();
         $selectRoles[0] = "Select / All";
         foreach ($roles as $role) {
             $selectRoles[$role->slug] = $role->name;
         }
         \View::share('selectRoles', $selectRoles);
     }
     if (\Schema::hasTable('provinces')) {
         $provinces = Province::all();
         $selectProvinces = array();
         $selectProvinces[0] = "Select / All";
         foreach ($provinces as $Province) {
             $selectProvinces[$Province->slug] = $Province->name;
         }
         \View::share('selectProvinces', $selectProvinces);
     }
     if (\Schema::hasTable('districts')) {
         $districts = District::all();
         $selectDistrict = array();
         $selectDistricts[0] = "Select / All";
         foreach ($districts as $district) {
             $selectDistricts[$district->slug] = $district->name;
         }
         \View::share('selectDistricts', $selectDistricts);
     }
     if (\Schema::hasTable('municipalities')) {
         $municipalities = Municipality::all();
         $selectMunicipalities = array();
         $selectMunicipalities[0] = "Select / All";
         foreach ($municipalities as $municipality) {
             $selectMunicipalities[$municipality->slug] = $municipality->name;
         }
         \View::share('selectMunicipalities', $selectMunicipalities);
     }
     if (\Schema::hasTable('wards')) {
         $wards = Ward::all();
         $selectWards = array();
         $selectWards[0] = "Select / All";
         foreach ($wards as $ward) {
             $selectWards[$ward->slug] = $ward->name;
         }
         \View::share('selectWards', $selectWards);
     }
     if (\Schema::hasTable('categories')) {
         $categories = Category::all();
         $selectCategories = array();
         $selectCategories[0] = "Select / All";
         foreach ($categories as $category) {
             $selectCategories[$category->slug] = $category->name;
         }
         \View::share('selectCategories', $selectCategories);
     }
     if (\Schema::hasTable('sub_categories')) {
         $subCategories = SubCategory::all();
         $selectSubCategories = array();
         $selectSubCategories[0] = "Select / All";
         foreach ($subCategories as $subCategory) {
             $selectSubCategories[$subCategory->slug] = $subCategory->name;
         }
         \View::share('selectSubCategories', $selectSubCategories);
     }
     if (\Schema::hasTable('sub_sub_categories')) {
         $subSubCategories = SubSubCategory::all();
         $selectSubSubCategories = array();
         $selectSubSubCategories[0] = "Select / All";
         foreach ($subSubCategories as $subSubCategory) {
             $selectSubSubCategories[$subSubCategory->slug] = $subSubCategory->name;
         }
         \View::share('selectSubSubCategories', $selectSubSubCategories);
     }
     if (\Schema::hasTable('relationships')) {
         $relationships = Relationship::all();
         $selectRelationships = array();
         $selectRelationships[0] = "Select / All";
         foreach ($relationships as $relationship) {
             $selectRelationships[$relationship->id] = $relationship->name;
         }
         \View::share('selectRelationships', $selectRelationships);
     }
     if (\Schema::hasTable('cases')) {
         $cases = \DB::table('cases')->join('users', 'cases.reporter', '=', 'users.id')->select(\DB::raw("\n                                                    IF(`cases`.`addressbook` = 1,(SELECT CONCAT(`first_name`, ' ', `surname`) FROM `addressbook` WHERE `addressbook`.`id`= `cases`.`reporter`), (SELECT CONCAT(users.`name`, ' ', users.`surname`) FROM `users` WHERE `users`.`id`= `cases`.`reporter`)) as reporterName\n\n                                                "))->get();
         $reporters = array();
         $reporters[0] = "Select / All";
         foreach ($cases as $case) {
             $reporters[$case->reporterName] = $case->reporterName;
         }
         \View::share('selectReporters', $reporters);
     }
     View()->composer('master', function ($view) {
         $view->with('addressBookNumber', addressbook::all());
         if (\Auth::check()) {
             $number = addressbook::where('user', '=', \Auth::user()->id)->get();
             $view->with('addressBookNumber', $number);
             $allUsers = User::where('id', '<>', \Auth::user()->id)->get();
             $view->with('loggedInUsers', $allUsers);
             $noPrivateMessages = Message::where('to', '=', \Auth::user()->id)->where('read', '=', 0)->where('message_type', '=', 0)->get();
             $view->with('noPrivateMessages', $noPrivateMessages);
             $noInboxMessages = Message::where('to', '=', \Auth::user()->id)->where('message_type', '=', 0)->get();
             $view->with('noInboxMessages', $noInboxMessages);
             $noDepartments = Department::all();
             $view->with('noDepartments', $noDepartments);
             $noUsers = User::all();
             $view->with('noUsers', $noUsers);
             $noRoles = UserRole::all();
             $view->with('noRoles', $noRoles);
             $noPositions = Position::all();
             $view->with('noPositions', $noPositions);
             $noRelationships = Relationship::all();
             $view->with('noRelationships', $noRelationships);
             $noProvinces = Province::all();
             $view->with('noProvinces', $noProvinces);
             $noCaseStatuses = CaseStatus::all();
             $view->with('noCaseStatuses', $noCaseStatuses);
             $userRole = UserRole::where('id', '=', \Auth::user()->role)->first();
             $view->with('systemRole', $userRole);
             $noCasesPriorities = CasePriority::all();
             $view->with('noCasesPriorities', $noCasesPriorities);
         }
     });
 }
Ejemplo n.º 23
0
 public function getMessages()
 {
     $messages = Message::where('user_id', Auth::user()->id)->where('archived', 0)->orderBy('created_at', 'DESC')->get();
     return json_encode($messages);
 }
Ejemplo n.º 24
0
 public function messages($school, $subject)
 {
     return Message::where('school_id', $school->id)->where('subject', $subject->id)->orderBy('created_at', 'DESC')->get();
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     if (\Schema::hasTable('positions')) {
         $positions = Position::orderBy('name', 'ASC')->get();
         $selectPositions = array();
         $selectPositions[0] = "Select / All";
         foreach ($positions as $position) {
             $selectPositions[$position->slug] = $position->name;
         }
         \View::share('selectPositions', $selectPositions);
     }
     if (\Schema::hasTable('departments')) {
         $departments = Department::orderBy('name', 'ASC')->get();
         $selectDepartments = array();
         $selectDepartments[0] = "Select / All";
         foreach ($departments as $department) {
             $selectDepartments[$department->slug] = $department->name;
         }
         \View::share('selectDepartments', $selectDepartments);
     }
     if (\Schema::hasTable('provinces')) {
         $provinces = Province::all();
         $selectProvinces = array();
         $selectProvinces[0] = "Select / All";
         foreach ($provinces as $Province) {
             $selectProvinces[$Province->slug] = $Province->name;
         }
         \View::share('selectProvinces', $selectProvinces);
     }
     if (\Schema::hasTable('districts')) {
         $districts = District::all();
         $selectDistrict = array();
         $selectDistricts[0] = "Select / All";
         foreach ($districts as $district) {
             $selectDistricts[$district->slug] = $district->name;
         }
         \View::share('selectDistricts', $selectDistricts);
     }
     if (\Schema::hasTable('municipalities')) {
         $municipalities = Municipality::all();
         $selectMunicipalities = array();
         $selectMunicipalities[0] = "Select / All";
         foreach ($municipalities as $municipality) {
             $selectMunicipalities[$municipality->slug] = $municipality->name;
         }
         \View::share('selectMunicipalities', $selectMunicipalities);
     }
     if (\Schema::hasTable('categories')) {
         $categories = Category::all();
         $selectCategories = array();
         $selectCategories[0] = "Select / All";
         foreach ($categories as $category) {
             $selectCategories[$category->slug] = $category->name;
         }
         \View::share('selectCategories', $selectCategories);
     }
     if (\Schema::hasTable('sub-categories')) {
         $subCategories = SubCategory::all();
         $selectSubCategories = array();
         $selectSubCategories[0] = "Select / All";
         foreach ($subCategories as $subCategory) {
             $selectSubCategories[$subCategory->slug] = $subCategory->name;
         }
         \View::share('selectSubCategories', $selectSubCategories);
     }
     if (\Schema::hasTable('sub-sub-categories')) {
         $subSubCategories = SubSubCategory::all();
         $selectSubSubCategories = array();
         $selectSubSubCategories[0] = "Select / All";
         foreach ($subSubCategories as $subSubCategory) {
             $selectSubSubCategories[$subSubCategory->slug] = $subSubCategory->name;
         }
         \View::share('selectSubSubCategories', $selectSubSubCategories);
     }
     if (\Schema::hasTable('relationships')) {
         $relationships = Relationship::all();
         $selectRelationships = array();
         $selectRelationships[0] = "Select / All";
         foreach ($relationships as $relationship) {
             $selectRelationships[$relationship->id] = $relationship->name;
         }
         \View::share('selectRelationships', $selectRelationships);
     }
     if (\Schema::hasTable('cases')) {
         $cases = \DB::table('cases')->join('users', 'cases.reporter', '=', 'users.id')->select(\DB::raw("\n                                                    IF(`cases`.`addressbook` = 1,(SELECT CONCAT(`FirstName`, ' ', `Surname`) FROM `addressbook` WHERE `addressbook`.`id`= `cases`.`reporter`), (SELECT CONCAT(users.`name`, ' ', users.`surname`) FROM `users` WHERE `users`.`id`= `cases`.`reporter`)) as reporterName\n\n                                                "))->get();
         $reporters = array();
         $reporters[0] = "Select / All";
         foreach ($cases as $case) {
             $reporters[$case->reporterName] = $case->reporterName;
         }
         \View::share('selectReporters', $reporters);
     }
     View()->composer('master', function ($view) {
         $view->with('addressBookNumber', addressbook::all());
         if (\Auth::check()) {
             $number = addressbook::where('user', '=', \Auth::user()->id)->get();
             $view->with('addressBookNumber', $number);
             $allUsers = User::where('id', '<>', \Auth::user()->id)->get();
             $view->with('loggedInUsers', $allUsers);
             $noPrivateMessages = Message::where('to', '=', \Auth::user()->id)->where('read', '=', 0)->where('online', '=', 0)->get();
             $view->with('noPrivateMessages', $noPrivateMessages);
             $noInboxMessages = Message::where('to', '=', \Auth::user()->id)->where('online', '=', 0)->get();
             $view->with('noInboxMessages', $noInboxMessages);
         }
     });
 }
Ejemplo n.º 26
0
 public function historyWithUser($userId)
 {
     return Message::where('sender_id', $this->id)->where('recipient_id', $userId)->orWhere('sender_id', $userId)->where('recipient_id', $this->id)->get();
 }
Ejemplo n.º 27
0
 public function getJsonMessageListData()
 {
     $data = Message::where('deleted_at', null)->get();
     return response($data);
 }
 /**
  * 获取category
  */
 public function category()
 {
     $category = Category::get();
     $n = count($category);
     for ($i = 0; $i < $n; ++$i) {
         $category[$i]->messages_num = Message::where('category', $category[$i]->id)->count();
     }
     return $category;
 }
Ejemplo n.º 29
0
        $html .= "<div class='media-body'>";
        $html .= "<span class='t-overflow p-t-5'>{$user->name}  {$user->surname} {$availability}</span>";
        $html .= "</div>";
        $html .= "</div>";
    }
    return $html;
});
/*
|--------------------------------------------------------------------------
| CASE MESSAGE ROUTING
|--------------------------------------------------------------------------
|
*/
Route::post('addCaseMessage', ['middleware' => 'auth', 'uses' => 'MessageController@store']);
Route::get('/getOfflineMessage', function () {
    $offlineMessages = Message::where('to', '=', \Auth::user()->id)->where('online', '=', 0)->orderBy('created_at', 'desc')->take(5)->get();
    $html = "";
    foreach ($offlineMessages as $message) {
        $user = User::where('id', '=', $message->from)->first();
        $read = $message->read == 0 ? "<span class='label label-danger'>New</span>" : "";
        $html .= "<div class='media'>";
        $html .= "<div class='pull-left'>";
        $html .= "<a href='#' onClick='chatStart(this)'> <img class='pull-left' src='img/profile-pics/7.png' width='30' alt=''></a>";
        $html .= "</div>";
        $html .= "<div class='media-body'>";
        $html .= "<small class='text-muted'>{$user->name}  {$user->surname} - {$message->created_at}</small> {$read}<br>";
        $html .= "<a class='t-overflow' href='message-detail/{$message->id}'>{$message->message} .Ref:Case ID {$message->caseId}</a>";
        $html .= "</div>";
        $html .= "</div>";
    }
    return $html;
Ejemplo n.º 30
0
 public function indexPage($page)
 {
     return App\Message::where('user_id', '=', Auth::id())->orderBy('id', 'desc')->skip(10 * ($page - 1))->take(10)->get();
 }