Upgrade to Laravel 9 (#4413)

Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
Matthew Penner 2022-10-14 10:59:20 -06:00 committed by GitHub
parent 95e15d2c8a
commit cbcf62086f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
573 changed files with 4387 additions and 9411 deletions

View file

@ -2,6 +2,9 @@
namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @property int $id
* @property string $uuid
@ -70,15 +73,11 @@ class Egg extends Model
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'eggs';
/**
* Fields that are not mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
@ -102,8 +101,6 @@ class Egg extends Model
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'nest_id' => 'integer',
@ -116,10 +113,7 @@ class Egg extends Model
'file_denylist' => 'array',
];
/**
* @var array
*/
public static $validationRules = [
public static array $validationRules = [
'nest_id' => 'required|bail|numeric|exists:nests,id',
'uuid' => 'required|string|size:36',
'name' => 'required|string|max:191',
@ -140,9 +134,6 @@ class Egg extends Model
'force_outgoing_ip' => 'sometimes|boolean',
];
/**
* @var array
*/
protected $attributes = [
'features' => null,
'file_denylist' => null,
@ -156,10 +147,8 @@ class Egg extends Model
/**
* Returns the install script for the egg; if egg is copying from another
* it will return the copied script.
*
* @return string
*/
public function getCopyScriptInstallAttribute()
public function getCopyScriptInstallAttribute(): ?string
{
if (!is_null($this->script_install) || is_null($this->copy_script_from)) {
return $this->script_install;
@ -171,10 +160,8 @@ class Egg extends Model
/**
* Returns the entry command for the egg; if egg is copying from another
* it will return the copied entry command.
*
* @return string
*/
public function getCopyScriptEntryAttribute()
public function getCopyScriptEntryAttribute(): string
{
if (!is_null($this->script_entry) || is_null($this->copy_script_from)) {
return $this->script_entry;
@ -186,10 +173,8 @@ class Egg extends Model
/**
* Returns the install container for the egg; if egg is copying from another
* it will return the copied install container.
*
* @return string
*/
public function getCopyScriptContainerAttribute()
public function getCopyScriptContainerAttribute(): string
{
if (!is_null($this->script_container) || is_null($this->copy_script_from)) {
return $this->script_container;
@ -200,10 +185,8 @@ class Egg extends Model
/**
* Return the file configuration for an egg.
*
* @return string
*/
public function getInheritConfigFilesAttribute()
public function getInheritConfigFilesAttribute(): ?string
{
if (!is_null($this->config_files) || is_null($this->config_from)) {
return $this->config_files;
@ -214,10 +197,8 @@ class Egg extends Model
/**
* Return the startup configuration for an egg.
*
* @return string
*/
public function getInheritConfigStartupAttribute()
public function getInheritConfigStartupAttribute(): ?string
{
if (!is_null($this->config_startup) || is_null($this->config_from)) {
return $this->config_startup;
@ -228,10 +209,8 @@ class Egg extends Model
/**
* Return the log reading configuration for an egg.
*
* @return string
*/
public function getInheritConfigLogsAttribute()
public function getInheritConfigLogsAttribute(): ?string
{
if (!is_null($this->config_logs) || is_null($this->config_from)) {
return $this->config_logs;
@ -242,10 +221,8 @@ class Egg extends Model
/**
* Return the stop command configuration for an egg.
*
* @return string
*/
public function getInheritConfigStopAttribute()
public function getInheritConfigStopAttribute(): ?string
{
if (!is_null($this->config_stop) || is_null($this->config_from)) {
return $this->config_stop;
@ -257,10 +234,8 @@ class Egg extends Model
/**
* Returns the features available to this egg from the parent configuration if there are
* no features defined for this egg specifically and there is a parent egg configured.
*
* @return array|null
*/
public function getInheritFeaturesAttribute()
public function getInheritFeaturesAttribute(): ?array
{
if (!is_null($this->features) || is_null($this->config_from)) {
return $this->features;
@ -272,10 +247,8 @@ class Egg extends Model
/**
* Returns the features available to this egg from the parent configuration if there are
* no features defined for this egg specifically and there is a parent egg configured.
*
* @return string[]|null
*/
public function getInheritFileDenylistAttribute()
public function getInheritFileDenylistAttribute(): ?array
{
if (is_null($this->config_from)) {
return $this->file_denylist;
@ -286,50 +259,40 @@ class Egg extends Model
/**
* Gets nest associated with an egg.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function nest()
public function nest(): BelongsTo
{
return $this->belongsTo(Nest::class);
}
/**
* Gets all servers associated with this egg.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function servers()
public function servers(): HasMany
{
return $this->hasMany(Server::class, 'egg_id');
}
/**
* Gets all variables associated with this egg.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function variables()
public function variables(): HasMany
{
return $this->hasMany(EggVariable::class, 'egg_id');
}
/**
* Get the parent egg from which to copy scripts.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function scriptFrom()
public function scriptFrom(): BelongsTo
{
return $this->belongsTo(self::class, 'copy_script_from');
}
/**
* Get the parent egg from which to copy configuration settings.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function configFrom()
public function configFrom(): BelongsTo
{
return $this->belongsTo(self::class, 'config_from');
}