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
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Pterodactyl\Models\Allocation.
|
||||
*
|
||||
|
@ -33,6 +35,7 @@ namespace Pterodactyl\Models;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|Allocation wherePort($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Allocation whereServerId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Allocation whereUpdatedAt($value)
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Allocation extends Model
|
||||
|
@ -45,22 +48,16 @@ class Allocation extends Model
|
|||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'allocations';
|
||||
|
||||
/**
|
||||
* Fields that are not mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* Cast values to correct type.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'node_id' => 'integer',
|
||||
|
@ -68,10 +65,7 @@ class Allocation extends Model
|
|||
'server_id' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public static $validationRules = [
|
||||
public static array $validationRules = [
|
||||
'node_id' => 'required|exists:nodes,id',
|
||||
'ip' => 'required|ip',
|
||||
'port' => 'required|numeric|between:1024,65535',
|
||||
|
@ -90,34 +84,24 @@ class Allocation extends Model
|
|||
|
||||
/**
|
||||
* Return a hashid encoded string to represent the ID of the allocation.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHashidAttribute()
|
||||
public function getHashidAttribute(): string
|
||||
{
|
||||
return app()->make('hashids')->encode($this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessor to automatically provide the IP alias if defined.
|
||||
*
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAliasAttribute($value)
|
||||
public function getAliasAttribute(?string $value): string
|
||||
{
|
||||
return (is_null($this->ip_alias)) ? $this->ip : $this->ip_alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessor to quickly determine if this allocation has an alias.
|
||||
*
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getHasAliasAttribute($value)
|
||||
public function getHasAliasAttribute(?string $value): bool
|
||||
{
|
||||
return !is_null($this->ip_alias);
|
||||
}
|
||||
|
@ -129,20 +113,16 @@ class Allocation extends Model
|
|||
|
||||
/**
|
||||
* Gets information for the server associated with this allocation.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function server()
|
||||
public function server(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Server::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Node model associated with this allocation.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function node()
|
||||
public function node(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Node::class);
|
||||
}
|
||||
|
|
Reference in a new issue