Пример #1
0
 public function hasLiked()
 {
     if (!\Auth::check()) {
         return false;
     }
     return app('App\\Repositories\\LikeRepository')->hasLiked('comment', $this->id, \Auth::user()->id);
 }
Пример #2
0
 /**
  * gets the user id of the current user
  * @return mixed
  */
 public static function userId()
 {
     if (Auth::check()) {
         return Auth::user()->user_id;
     } else {
         return 0;
     }
 }
Пример #3
0
 public function isOwner()
 {
     if (!\Auth::check()) {
         return false;
     }
     if (\Auth::user()->id == $this->user_id) {
         return true;
     }
     return false;
 }
Пример #4
0
 public static function isSuperAdmin()
 {
     if (\Auth::check()) {
         if (\Auth::user()->role_id == 1) {
             return true;
         }
         return false;
     }
     return false;
 }
Пример #5
0
 public static function generate()
 {
     if (!\Auth::check()) {
         return NULL;
     }
     $apiKey = new ApiKey();
     $apiKey->user_id = \Auth::user()->id;
     $apiKey->api_key = \App\Helpers\Text::randomCryptoString();
     $apiKey->save();
     return $apiKey;
 }
Пример #6
0
 public function isOwner($userid = null)
 {
     if (!\Auth::check()) {
         return false;
     }
     $userid = empty($userid) ? \Auth::user()->id : $userid;
     if ($this->user_id == $userid) {
         return true;
     }
     return false;
 }
Пример #7
0
 public function scopeUserUnread($query, $uid = false)
 {
     $uid = $uid == false && \Auth::check() ? \Auth::user()->id : $uid;
     return $query->whereRaw("recipient_id = {$uid} AND unread = 1");
 }
Пример #8
0
 public function scopeFilters($query)
 {
     switch (Request::input('filter')) {
         case 'qualified':
             $filter = static::QUALIFIED;
             break;
         case 'ranked':
             $filter = static::RANKED;
             break;
         case 'approved':
             $filter = static::APPROVED;
             break;
         case 'modreq':
         case 'pending':
             $filter = static::PENDING;
             break;
         case 'all':
             return $query;
         case 'graveyard':
             $filter = static::GRAVEYARD;
             break;
         case 'my-maps':
             if (Auth::check()) {
                 return $query->where('user_id', '=', Auth::user()->user_id);
             }
         case 'faves':
             return $query->faves();
         case 'ranked-approved':
         default:
             return $query->whereIn('approved', [static::RANKED, static::APPROVED]);
     }
     return $query->where('approved', '=', $filter);
 }
Пример #9
0
 /**
  * Easy method to check if the login user is the owner of this user
  *
  * @return boolean
  */
 public function isOwner()
 {
     return \Auth::check() and \Auth::user()->id == $this->id;
 }
Пример #10
0
 public function scopeFilters($query)
 {
     switch (Request::input("filter")) {
         case "qualified":
             $filter = static::QUALIFIED;
             break;
         case "ranked":
             $filter = static::RANKED;
             break;
         case "approved":
             $filter = static::APPROVED;
             break;
         case "modreq":
         case "pending":
             $filter = static::PENDING;
             break;
         case "all":
             return $query;
         case "graveyard":
             $filter = static::GRAVEYARD;
             break;
         case "my-maps":
             if (Auth::check()) {
                 return $query->where("user_id", "=", Auth::user()->user_id);
             }
         case "faves":
             return $query->faves();
         case "ranked-approved":
         default:
             return $query->whereIn("approved", [static::RANKED, static::APPROVED]);
     }
     return $query->where("approved", "=", $filter);
 }