public function unreadMessagesCount() { return Message::where('to_user_id', $this->id)->where('read', 0)->count(); }
/** * Display a listing of the resource. * * @return Response */ public function index() { return view('materialadmin::message.index')->with('messages', Message::where('to_user_id', \Auth::id())->orderBy('created_at', 'desc')->paginate(15)); }