本文整理汇总了PHP中app\Message::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::where方法的具体用法?PHP Message::where怎么用?PHP Message::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Message
的用法示例。
在下文中一共展示了Message::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: refresh
public function refresh()
{
$count = Message::where('id_receive', \Auth::user()->id)->where('read', NULL)->count();
if ($count) {
return $count;
}
}
示例2: index
/**
* 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);
}
示例3: getConversation
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()]);
}
示例4: index
/**
* 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]);
}
示例5: show
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);
}
示例6: show
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]);
}
示例7: dashboard
/**
* 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);
}
示例8: getSend
/**
* 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'));
}
示例9: searchTickets
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'));
}
示例10: index
/**
* 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);
}
示例11: show
/**
* 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'));
}
示例12: save
/**
* 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;
}
示例13: hasNewMessages
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;
}
}
示例14: boot
/**
* 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);
});
}
示例15: __construct
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']]);
}