1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-25 10:32:31 +01:00

Fix casts on models; closes #49

This commit is contained in:
Dane Everitt 2016-01-26 22:17:51 -05:00
parent fa6a535349
commit d6bd7e7a2e
10 changed files with 116 additions and 0 deletions

View File

@ -42,6 +42,15 @@ class APIPermission extends Model
*/
protected $guarded = ['id'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'key_id' => 'integer',
];
/**
* Disable timestamps for this table.
*

View File

@ -42,4 +42,15 @@ class Allocation extends Model
*/
protected $guarded = ['id', 'created_at', 'updated_at'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'node' => 'integer',
'port' => 'integer',
'assigned_to' => 'integer',
];
}

View File

@ -43,6 +43,20 @@ class Node extends Model
*/
protected $hidden = ['daemonSecret'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'public' => 'integer',
'location' => 'integer',
'memory' => 'integer',
'disk' => 'integer',
'daemonListen' => 'integer',
'daemonSFTP' => 'integer',
];
/**
* Fields that are not mass assignable.
*

View File

@ -42,6 +42,16 @@ class Permission extends Model
*/
protected $guarded = ['id', 'created_at', 'updated_at'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'user_id' => 'integer',
'server_id' => 'integer',
];
public function scopePermission($query, $permission)
{
return $query->where('permission', $permission);

View File

@ -52,6 +52,27 @@ class Server extends Model
*/
protected $guarded = ['id', 'installed', 'created_at', 'updated_at'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'node' => 'integer',
'active' => 'integer',
'owner' => 'integer',
'memory' => 'integer',
'swap' => 'integer',
'disk' => 'integer',
'io' => 'integer',
'cpu' => 'integer',
'oom_disabled' => 'integer',
'port' => 'integer',
'service' => 'integer',
'option' => 'integer',
'installed' => 'integer',
];
/**
* @var array
*/

View File

@ -42,4 +42,14 @@ class ServerVariables extends Model
*/
protected $guarded = ['id', 'created_at', 'updated_at'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'server_id' => 'integer',
'variable_id' => 'integer',
];
}

View File

@ -35,4 +35,13 @@ class ServiceOptions extends Model
*/
protected $table = 'service_options';
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'parent_service' => 'integer',
];
}

View File

@ -35,4 +35,16 @@ class ServiceVariables extends Model
*/
protected $table = 'service_variables';
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'option_id' => 'integer',
'user_viewable' => 'integer',
'user_editable' => 'integer',
'required' => 'integer',
];
}

View File

@ -50,6 +50,16 @@ class Subuser extends Model
*/
protected $guarded = ['id', 'created_at', 'updated_at'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'user_id' => 'integer',
'server_id' => 'integer',
];
/**
* @var mixed
*/

View File

@ -57,6 +57,16 @@ class User extends Model implements AuthenticatableContract,
*/
protected $guarded = ['id', 'remeber_token', 'created_at', 'updated_at'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'root_admin' => 'integer',
'use_totp' => 'integer',
];
/**
* The attributes excluded from the model's JSON form.
*