コード例 #1
0
ファイル: User.php プロジェクト: stickableapp/stickable-api
 /**
  * @return array
  */
 public function toArray()
 {
     $array = parent::toArray();
     if (!Auth::check() || Auth::user()->id !== $this->id) {
         unset($array['email']);
         unset($array['admin']);
         unset($array['updatedAt']);
     }
     if ($image = $this->getImage()) {
         $array['imageUrl'] = $image->getUrl();
         $array['imageThumbUrl'] = $image->thumb ? $image->getThumbUrl() : $image->getUrl();
     } else {
         $array['imageUrl'] = null;
         $array['imageThumbUrl'] = null;
     }
     $array['possessiveName'] = LangHelpers::possessive($this->username);
     return $array;
 }
コード例 #2
0
 /**
  * Get the list of usernames to display in the notification.
  *
  * 1 user: nameA
  * 2 users: nameA and nameB
  * 3 users: nameA, nameB and nameC
  * 4+ users: nameA, nameB, and 2+ others
  *
  * @return null|string
  */
 protected function getUsernameText()
 {
     if ($userIds = $this->getFromUserIds()) {
         $userIdCount = count($userIds);
         $showUsernameCount = $userIdCount > 3 ? 2 : 3;
         $usernames = $this->getFromUsernames($showUsernameCount);
         if ($userIdCount <= 3) {
             $usernameStr = LangHelpers::naturalLanguageImplode($usernames);
         } else {
             $usernameStr = implode(', ', $usernames);
             $remaining = $userIdCount - $showUsernameCount;
             $usernameStr .= ', ' . Lang::get('notifications.andothers', ['count' => $remaining]);
         }
         return $usernameStr;
     }
     return null;
 }