Upgrade to Laravel 9 (#4413)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
parent
95e15d2c8a
commit
cbcf62086f
573 changed files with 4387 additions and 9411 deletions
|
@ -75,6 +75,7 @@ use Pterodactyl\Notifications\SendPasswordReset as ResetPasswordNotification;
|
|||
* @method static Builder|User whereUseTotp($value)
|
||||
* @method static Builder|User whereUsername($value)
|
||||
* @method static Builder|User whereUuid($value)
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class User extends Model implements
|
||||
|
@ -100,22 +101,16 @@ class User extends Model implements
|
|||
|
||||
/**
|
||||
* Level of servers to display when using access() on a user.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $accessLevel = 'all';
|
||||
protected string $accessLevel = 'all';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'users';
|
||||
|
||||
/**
|
||||
* A list of mass-assignable variables.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'external_id',
|
||||
|
@ -134,8 +129,6 @@ class User extends Model implements
|
|||
|
||||
/**
|
||||
* Cast values to correct type.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'root_admin' => 'boolean',
|
||||
|
@ -143,22 +136,15 @@ class User extends Model implements
|
|||
'gravatar' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = ['totp_authenticated_at'];
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['password', 'remember_token', 'totp_secret', 'totp_authenticated_at'];
|
||||
|
||||
/**
|
||||
* Default values for specific fields in the database.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $attributes = [
|
||||
'external_id' => null,
|
||||
|
@ -170,10 +156,8 @@ class User extends Model implements
|
|||
|
||||
/**
|
||||
* Rules verifying that the data being stored matches the expectations of the database.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $validationRules = [
|
||||
public static array $validationRules = [
|
||||
'uuid' => 'required|string|size:36|unique:users,uuid',
|
||||
'email' => 'required|email|between:1,191|unique:users,email',
|
||||
'external_id' => 'sometimes|nullable|string|max:191|unique:users,external_id',
|
||||
|
@ -191,7 +175,7 @@ class User extends Model implements
|
|||
* Implement language verification by overriding Eloquence's gather
|
||||
* rules function.
|
||||
*/
|
||||
public static function getRules()
|
||||
public static function getRules(): array
|
||||
{
|
||||
$rules = parent::getRules();
|
||||
|
||||
|
@ -234,37 +218,27 @@ class User extends Model implements
|
|||
|
||||
/**
|
||||
* Return a concatenated result for the accounts full name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNameAttribute()
|
||||
public function getNameAttribute(): string
|
||||
{
|
||||
return trim($this->name_first . ' ' . $this->name_last);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all servers that a user owns.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function servers()
|
||||
public function servers(): HasMany
|
||||
{
|
||||
return $this->hasMany(Server::class, 'owner_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function apiKeys()
|
||||
public function apiKeys(): HasMany
|
||||
{
|
||||
return $this->hasMany(ApiKey::class)
|
||||
->where('key_type', ApiKey::TYPE_ACCOUNT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function recoveryTokens()
|
||||
public function recoveryTokens(): HasMany
|
||||
{
|
||||
return $this->hasMany(RecoveryToken::class);
|
||||
}
|
||||
|
@ -275,7 +249,7 @@ class User extends Model implements
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns all of the activity logs where this user is the subject — not to
|
||||
* Returns all the activity logs where this user is the subject — not to
|
||||
* be confused by activity logs where this user is the _actor_.
|
||||
*/
|
||||
public function activity(): MorphToMany
|
||||
|
@ -284,12 +258,10 @@ class User extends Model implements
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns all of the servers that a user can access by way of being the owner of the
|
||||
* Returns all the servers that a user can access by way of being the owner of the
|
||||
* server, or because they are assigned as a subuser for that server.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function accessibleServers()
|
||||
public function accessibleServers(): Builder
|
||||
{
|
||||
return Server::query()
|
||||
->select('servers.*')
|
||||
|
|
Reference in a new issue