/** * Method to get the proper user */ public function theUser() { if ($this->entity->user1 == \Auth::user()->id) { return $this->entity->userTwo; } else { return $this->entity->userOne; } }
public function canDelete() { if (!\Auth::check()) { return false; } if (\Auth::user()->id == $this->entity->user_id or \Auth::user()->isAdmin()) { return true; } return false; }
public function isEditor() { if (!\Auth::check()) { return false; } $userid = \Auth::user()->id; $adminRepository = app('App\\Repositories\\EventAdminRepository'); if ($adminRepository->isEditor($this->entity->id, $userid)) { return true; } return false; }
public function canView() { $userid = \Auth::user()->id; if ($userid == $this->entity->receiver and $this->entity->seen == 0) { $this->entity->seen = 1; $this->entity->save(); } if ($this->entity->sender_status == 1 and $this->entity->receiver_status == 1) { //return false and delete the message $this->entity->delete(); return false; } if ($userid == $this->entity->sender) { if ($this->entity->sender_status == 0) { return true; } } else { if ($this->entity->receiver_status == 0) { return true; } } return false; }
public function isModerator($userid = null) { if (!\Auth::check()) { return false; } $moderators = $this->entity->getModerators(); $userid = empty($userid) ? \Auth::user()->id : $userid; return in_array($userid, $moderators); }
public function canSeeBirth() { if (\Auth::check() and $this->entity->id == \Auth::user()->id) { return true; } //viewer is the owner //for admin to be able to view private profile if (\Auth::check() and \Auth::user()->isAdmin()) { return true; } $privacy = $this->privacy('view-birth', 'public'); if ($privacy == 'public') { return true; } elseif ($privacy == 'nobody') { return false; } else { $connection = app('App\\Repositories\\ConnectionRepository'); if ($privacy == 'friends') { if (\Auth::check() and $connection->areFriends($this->entity->id, \Auth::user()->id)) { return true; } return false; } elseif ($privacy == "friend-follower") { if (\Auth::check() and $connection->areFriends($this->entity->id, \Auth::user()->id)) { return true; } //now check for follower if (\Auth::check() and $connection->isFollowing(\Auth::user()->id, $this->entity->id)) { return true; } return false; } } }