'integer', 'privileges_version' => 'integer', 'user_jwt_issued_at' => 'datetime', 'user_jwt_expires_at' => 'datetime', ]; } public function jwtNeedsRefresh(int $refreshIntervalSeconds = 3600): bool { if (blank($this->user_jwt) || ! $this->user_jwt_issued_at) { return true; } return $this->user_jwt_issued_at->lte(now()->subSeconds($refreshIntervalSeconds)); } public function markPrivilegesChanged(): void { $this->increment('privileges_version'); } public function getName() { return $this->character_name; } public function getId() { return $this->character_id; } public function getRole() { $role = UserRole::where([ 'character_id' => $this->character_id, ])->first(); return $role->role; } public function hasRole($role) { //If the user is a super use then he has all roles if($this->hasSuperUser()) { return true; } $found = UserRole::where(['character_id' => $this->character_id, 'role' => $role])->get(['role']); if(isset($found[0]) && $found[0]->role == $role) { return true; } else { return false; } } public function hasSuperUser() { $found = UserRole::where(['character_id' => $this->character_id])->first(); if(isset($found[0]->role) && $found[0]->role == 'SuperUser') { return true; } else { return false; } } public function srpOpen() { return SRPShips::where([ 'character_id' => $this->character_id, 'approval' => 'Under Review', ])->count(); } public function srpDenied() { return SRPShips::where([ 'character_id' => $this->character_id, 'approval' => 'Denied', ])->count(); } public function srpApproved() { return SRPShips::where([ 'character_id' => $this->character_id, 'approval' => 'Approved', ])->count(); } }