app: update models

This commit is contained in:
Matthew Penner 2021-07-17 15:18:05 -06:00
parent 28bc86e23b
commit 9d64c6751b
25 changed files with 55 additions and 54 deletions

View File

@ -48,7 +48,7 @@ class AdminRole extends Model
/** /**
* @var array * @var array
*/ */
public static $validationRules = [ public static array $validationRules = [
'name' => 'required|string|max:64', 'name' => 'required|string|max:64',
'description' => 'nullable|string|max:255', 'description' => 'nullable|string|max:255',
'sort_id' => 'sometimes|numeric', 'sort_id' => 'sometimes|numeric',

View File

@ -53,7 +53,7 @@ class Allocation extends Model
/** /**
* @var array * @var array
*/ */
public static $validationRules = [ public static array $validationRules = [
'node_id' => 'required|exists:nodes,id', 'node_id' => 'required|exists:nodes,id',
'ip' => 'required|ip', 'ip' => 'required|ip',
'port' => 'required|numeric|between:1024,65535', 'port' => 'required|numeric|between:1024,65535',

View File

@ -97,7 +97,7 @@ class ApiKey extends Model
* *
* @var array * @var array
*/ */
public static $validationRules = [ public static array $validationRules = [
'user_id' => 'required|exists:users,id', 'user_id' => 'required|exists:users,id',
'key_type' => 'present|integer|min:0|max:4', 'key_type' => 'present|integer|min:0|max:4',
'identifier' => 'required|string|size:16|unique:api_keys,identifier', 'identifier' => 'required|string|size:16|unique:api_keys,identifier',

View File

@ -63,7 +63,7 @@ class AuditLog extends Model
/** /**
* @var bool * @var bool
*/ */
protected $immutableDates = true; protected bool $immutableDates = true;
/** /**
* @var string[] * @var string[]

View File

@ -40,7 +40,7 @@ class Backup extends Model
/** /**
* @var bool * @var bool
*/ */
protected $immutableDates = true; protected bool $immutableDates = true;
/** /**
* @var array * @var array
@ -79,7 +79,7 @@ class Backup extends Model
/** /**
* @var array * @var array
*/ */
public static $validationRules = [ public static array $validationRules = [
'server_id' => 'bail|required|numeric|exists:servers,id', 'server_id' => 'bail|required|numeric|exists:servers,id',
'uuid' => 'required|uuid', 'uuid' => 'required|uuid',
'is_successful' => 'boolean', 'is_successful' => 'boolean',

View File

@ -61,7 +61,7 @@ class Database extends Model
/** /**
* @var array * @var array
*/ */
public static $validationRules = [ public static array $validationRules = [
'server_id' => 'required|numeric|exists:servers,id', 'server_id' => 'required|numeric|exists:servers,id',
'database_host_id' => 'required|exists:database_hosts,id', 'database_host_id' => 'required|exists:database_hosts,id',
'database' => 'required|string|alpha_dash|between:3,48', 'database' => 'required|string|alpha_dash|between:3,48',

View File

@ -24,7 +24,7 @@ class DatabaseHost extends Model
/** /**
* @var bool * @var bool
*/ */
protected $immutableDates = true; protected bool $immutableDates = true;
/** /**
* The table associated with the model. * The table associated with the model.

View File

@ -111,7 +111,7 @@ class Egg extends Model
/** /**
* @var array * @var array
*/ */
public static $validationRules = [ public static array $validationRules = [
'nest_id' => 'required|bail|numeric|exists:nests,id', 'nest_id' => 'required|bail|numeric|exists:nests,id',
'uuid' => 'required|string|size:36', 'uuid' => 'required|string|size:36',
'name' => 'required|string|max:191', 'name' => 'required|string|max:191',

View File

@ -40,7 +40,7 @@ class EggVariable extends Model
/** /**
* @var bool * @var bool
*/ */
protected $immutableDates = true; protected bool $immutableDates = true;
/** /**
* The table associated with the model. * The table associated with the model.

View File

@ -38,7 +38,7 @@ class Location extends Model
* *
* @var array * @var array
*/ */
public static $validationRules = [ public static array $validationRules = [
'short' => 'required|string|between:1,60|unique:locations,short', 'short' => 'required|string|between:1,60|unique:locations,short',
'long' => 'string|nullable|between:1,191', 'long' => 'string|nullable|between:1,191',
]; ];

View File

@ -20,7 +20,7 @@ abstract class Model extends IlluminateModel
* *
* @var bool * @var bool
*/ */
protected $immutableDates = false; protected bool $immutableDates = false;
/** /**
* Determines if the model should undergo data validation before it is saved * Determines if the model should undergo data validation before it is saved
@ -45,7 +45,7 @@ abstract class Model extends IlluminateModel
/** /**
* @var array * @var array
*/ */
public static $validationRules = []; public static array $validationRules = [];
/** /**
* Listen for the model saving event and fire off the validation * Listen for the model saving event and fire off the validation

View File

@ -52,10 +52,8 @@ class Mount extends Model
/** /**
* Rules verifying that the data being stored matches the expectations of the database. * Rules verifying that the data being stored matches the expectations of the database.
*
* @var string
*/ */
public static $validationRules = [ public static array $validationRules = [
'name' => 'required|string|min:2|max:64|unique:mounts,name', 'name' => 'required|string|min:2|max:64|unique:mounts,name',
'description' => 'nullable|string|max:191', 'description' => 'nullable|string|max:191',
'source' => 'required|string', 'source' => 'required|string',

View File

@ -38,10 +38,7 @@ class Nest extends Model
'description', 'description',
]; ];
/** public static array $validationRules = [
* @var array
*/
public static $validationRules = [
'author' => 'sometimes|string|email', 'author' => 'sometimes|string|email',
'name' => 'required|string|max:191', 'name' => 'required|string|max:191',
'description' => 'nullable|string', 'description' => 'nullable|string',

View File

@ -100,10 +100,7 @@ class Node extends Model
'description', 'maintenance_mode', 'description', 'maintenance_mode',
]; ];
/** public static array $validationRules = [
* @var array
*/
public static $validationRules = [
'name' => 'required|regex:/^([\w .-]{1,100})$/', 'name' => 'required|regex:/^([\w .-]{1,100})$/',
'description' => 'string|nullable', 'description' => 'string|nullable',
'location_id' => 'required|exists:locations,id', 'location_id' => 'required|exists:locations,id',

View File

@ -96,7 +96,7 @@ class Permission extends Model
/** /**
* @var array * @var array
*/ */
public static $validationRules = [ public static array $validationRules = [
'subuser_id' => 'required|numeric|min:1', 'subuser_id' => 'required|numeric|min:1',
'permission' => 'required|string', 'permission' => 'required|string',
]; ];

View File

@ -21,15 +21,9 @@ class RecoveryToken extends Model
*/ */
public $timestamps = true; public $timestamps = true;
/** protected bool $immutableDates = true;
* @var bool
*/
protected $immutableDates = true;
/** public static array $validationRules = [
* @var string[]
*/
public static $validationRules = [
'token' => 'required|string', 'token' => 'required|string',
]; ];

View File

@ -105,10 +105,7 @@ class Schedule extends Model
'only_when_online' => false, 'only_when_online' => false,
]; ];
/** public static array $validationRules = [
* @var array
*/
public static $validationRules = [
'server_id' => 'required|exists:servers,id', 'server_id' => 'required|exists:servers,id',
'name' => 'required|string|max:191', 'name' => 'required|string|max:191',
'cron_day_of_week' => 'required|string', 'cron_day_of_week' => 'required|string',

View File

@ -107,10 +107,7 @@ class Server extends Model
*/ */
protected $guarded = ['id', self::CREATED_AT, self::UPDATED_AT, 'deleted_at']; protected $guarded = ['id', self::CREATED_AT, self::UPDATED_AT, 'deleted_at'];
/** public static array $validationRules = [
* @var array
*/
public static $validationRules = [
'external_id' => 'sometimes|nullable|string|between:1,191|unique:servers', 'external_id' => 'sometimes|nullable|string|between:1,191|unique:servers',
'owner_id' => 'required|integer|exists:users,id', 'owner_id' => 'required|integer|exists:users,id',
'name' => 'required|string|min:1|max:191', 'name' => 'required|string|min:1|max:191',

View File

@ -61,7 +61,7 @@ class ServerTransfer extends Model
/** /**
* @var array * @var array
*/ */
public static $validationRules = [ public static array $validationRules = [
'server_id' => 'required|numeric|exists:servers,id', 'server_id' => 'required|numeric|exists:servers,id',
'old_node' => 'required|numeric', 'old_node' => 'required|numeric',
'new_node' => 'required|numeric', 'new_node' => 'required|numeric',

View File

@ -20,23 +20,18 @@ class ServerVariable extends Model
*/ */
public const RESOURCE_NAME = 'server_variable'; public const RESOURCE_NAME = 'server_variable';
/** @var bool */
protected $immutableDates = true;
/** @var string */
protected $table = 'server_variables'; protected $table = 'server_variables';
/** @var string[] */ protected bool $immutableDates = true;
protected $guarded = ['id', 'created_at', 'updated_at']; protected $guarded = ['id', 'created_at', 'updated_at'];
/** @var string[] */
protected $casts = [ protected $casts = [
'server_id' => 'integer', 'server_id' => 'integer',
'variable_id' => 'integer', 'variable_id' => 'integer',
]; ];
/** @var string[] */ public static array $validationRules = [
public static $validationRules = [
'server_id' => 'required|int', 'server_id' => 'required|int',
'variable_id' => 'required|int', 'variable_id' => 'required|int',
'variable_value' => 'string', 'variable_value' => 'string',

View File

@ -24,7 +24,7 @@ class Setting extends Model
/** /**
* @var array * @var array
*/ */
public static $validationRules = [ public static array $validationRules = [
'key' => 'required|string|between:1,191', 'key' => 'required|string|between:1,191',
'value' => 'string', 'value' => 'string',
]; ];

View File

@ -52,7 +52,7 @@ class Subuser extends Model
/** /**
* @var array * @var array
*/ */
public static $validationRules = [ public static array $validationRules = [
'user_id' => 'required|numeric|exists:users,id', 'user_id' => 'required|numeric|exists:users,id',
'server_id' => 'required|numeric|exists:servers,id', 'server_id' => 'required|numeric|exists:servers,id',
'permissions' => 'nullable|array', 'permissions' => 'nullable|array',

View File

@ -95,7 +95,7 @@ class Task extends Model
/** /**
* @var array * @var array
*/ */
public static $validationRules = [ public static array $validationRules = [
'schedule_id' => 'required|numeric|exists:schedules,id', 'schedule_id' => 'required|numeric|exists:schedules,id',
'sequence_id' => 'required|numeric|min:1', 'sequence_id' => 'required|numeric|min:1',
'action' => 'required|string', 'action' => 'required|string',

View File

@ -138,7 +138,7 @@ class User extends Model implements
* *
* @var array * @var array
*/ */
public static $validationRules = [ public static array $validationRules = [
'uuid' => 'required|string|size:36|unique:users,uuid', 'uuid' => 'required|string|size:36|unique:users,uuid',
'email' => 'required|email|between:1,191|unique:users,email', 'email' => 'required|email|between:1,191|unique:users,email',
'external_id' => 'sometimes|nullable|string|max:191|unique:users,external_id', 'external_id' => 'sometimes|nullable|string|max:191|unique:users,external_id',

26
app/Models/UserSSHKey.php Normal file
View File

@ -0,0 +1,26 @@
<?php
namespace Pterodactyl\Models;
/**
* @property int $id
* @property int $user_id
* @property string $name
* @property string $public_key
* @property \Carbon\CarbonImmutable $created_at
*/
class UserSSHKey extends Model
{
protected $table = 'user_ssh_keys';
protected bool $immutableDates = true;
/**
* @var string[]
*/
protected $guarded = ['id', 'created_at'];
public static array $validationRules = [
'name' => 'required|string',
'public_key' => 'required|string',
];
}