コード例 #1
0
ファイル: FakeSeeder.php プロジェクト: strimoid/strimoid
 protected function createFakeGroup(User $creator)
 {
     $group = Group::create(['created_at' => $this->faker->dateTimeThisDecade, 'creator_id' => $creator->getKey(), 'name' => $this->faker->city, 'description' => implode(' ', $this->faker->sentences(2)), 'sidebar' => $this->faker->paragraph, 'urlname' => $this->faker->domainWord]);
     $contentsNumber = $this->faker->numberBetween(0, 5);
     for ($i = 0; $i < $contentsNumber; $i++) {
         $this->createFakeContent($group);
         $this->createFakeEntry($group);
     }
     $subscribersNumber = $this->faker->numberBetween(0, count($this->users));
     for ($i = 0; $i < $subscribersNumber; $i++) {
         $subscriber = $this->users[$i];
         $this->createFakeSubscriber($group, $subscriber);
     }
 }
コード例 #2
0
 /**
  * Checks that user is not "myself" or is not blocked by notification target user
  */
 public function isNotMyselfOrBlockedByReceiver(User $sourceUser, User $targetUser)
 {
     if ($targetUser->getKey() != $sourceUser->getKey() && !$targetUser->isBlockingUser($sourceUser)) {
         return true;
     }
     return false;
 }
コード例 #3
0
ファイル: Entry.php プロジェクト: strimoid/strimoid
 public function isAuthor(User $user = null)
 {
     $userId = $user ? $user->getKey() : auth()->id();
     return (int) $userId === (int) $this->user_id;
 }
コード例 #4
0
ファイル: Content.php プロジェクト: strimoid/strimoid
 public function canEdit(User $user = null)
 {
     $isAuthor = $user->getKey() == $this->user_id;
     $hasTime = $this->created_at->diffInMinutes() < 30;
     $isAdmin = $user->type == 'admin';
     return $isAuthor && $hasTime || $isAdmin;
 }
コード例 #5
0
ファイル: VoteController.php プロジェクト: strimoid/strimoid
 private function getVoteElement($object, User $user)
 {
     if (!$object->votes()) {
         return false;
     }
     $vote = $object->votes()->where('user_id', $user->getKey())->first();
     if (!$vote) {
         return false;
     }
     return $vote;
 }