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

@ -7,6 +7,9 @@ use Symfony\Component\Yaml\Yaml;
use Illuminate\Container\Container;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
/**
* @property int $id
@ -51,22 +54,16 @@ class Node extends Model
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'nodes';
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['daemon_token_id', 'daemon_token'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'location_id' => 'integer',
@ -81,8 +78,6 @@ class Node extends Model
/**
* Fields that are mass assignable.
*
* @var array
*/
protected $fillable = [
'public', 'name', 'location_id',
@ -93,10 +88,7 @@ class Node extends Model
'description', 'maintenance_mode',
];
/**
* @var array
*/
public static $validationRules = [
public static array $validationRules = [
'name' => 'required|regex:/^([\w .-]{1,100})$/',
'description' => 'string|nullable',
'location_id' => 'required|exists:locations,id',
@ -117,8 +109,6 @@ class Node extends Model
/**
* Default values for specific columns that are generally not changed on base installs.
*
* @var array
*/
protected $attributes = [
'public' => true,
@ -141,10 +131,8 @@ class Node extends Model
/**
* Returns the configuration as an array.
*
* @return array
*/
public function getConfiguration()
public function getConfiguration(): array
{
return [
'debug' => false,
@ -174,20 +162,16 @@ class Node extends Model
/**
* Returns the configuration in Yaml format.
*
* @return string
*/
public function getYamlConfiguration()
public function getYamlConfiguration(): string
{
return Yaml::dump($this->getConfiguration(), 4, 2, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE);
}
/**
* Returns the configuration in JSON format.
*
* @return string
*/
public function getJsonConfiguration(bool $pretty = false)
public function getJsonConfiguration(bool $pretty = false): string
{
return json_encode($this->getConfiguration(), $pretty ? JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT : JSON_UNESCAPED_SLASHES);
}
@ -202,40 +186,31 @@ class Node extends Model
);
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
*/
public function mounts()
public function mounts(): HasManyThrough
{
return $this->hasManyThrough(Mount::class, MountNode::class, 'node_id', 'id', 'id', 'mount_id');
}
/**
* Gets the location associated with a node.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function location()
public function location(): BelongsTo
{
return $this->belongsTo(Location::class);
}
/**
* Gets the servers associated with a node.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function servers()
public function servers(): HasMany
{
return $this->hasMany(Server::class);
}
/**
* Gets the allocations associated with a node.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function allocations()
public function allocations(): HasMany
{
return $this->hasMany(Allocation::class);
}