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; }
/** * @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; }
/** * 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; } } }
/** * 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; }
public function checkFollow() { if (\Auth::guest()) { return false; } else { if ($this->followedUsers()->where('id', \Auth::user()->id)->first() === NULL) { return false; } else { return true; } } }