Exemplo n.º 1
0
 public function unReadCount()
 {
     if (\Auth::guest()) {
         return 0;
     }
     if ($this->userReadDiscussion->count() > 0) {
         return $this->total_comments - $this->userReadDiscussion->first()->read_comments;
     }
     return $this->total_comments;
 }
Exemplo n.º 2
0
 /**
  * @todo this is f*****g gross
  */
 public function getCompletedAttribute()
 {
     if (\Auth::guest()) {
         return false;
     }
     $entry = Entry::where('goal_id', $this->id)->where('user_id', \Auth::user()->id)->where('completed_on', Carbon::today())->first();
     if ($entry) {
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  * Check whether this article got favor by logged in user or not
  *
  * @return boolen
  */
 public function checkFavorite()
 {
     if (\Auth::guest()) {
         return false;
     } else {
         if ($this->favorites()->where('id', \Auth::user()->id)->first() === NULL) {
             return false;
         } else {
             return true;
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Check if user is a admin of this project
  *
  * @return boolean
  */
 public function isProjectAdmin($user_id = null)
 {
     if (!Auth::guest()) {
         if ($user_id == null) {
             $user_id = Auth::user()->id;
         }
         $isAdmin = ProjectMember::where('user_id', '=', $user_id)->where('project_id', '=', $this->id)->first();
         if ($isAdmin != null) {
             $isAdmin = true;
         } else {
             $isAdmin = false;
         }
     } else {
         $isAdmin = false;
     }
     return $isAdmin;
 }
Exemplo n.º 5
0
 public function checkFollow()
 {
     if (\Auth::guest()) {
         return false;
     } else {
         if ($this->followedUsers()->where('id', \Auth::user()->id)->first() === NULL) {
             return false;
         } else {
             return true;
         }
     }
 }