Model updates for Database Management in ACP
This commit is contained in:
parent
9c2d34d6e6
commit
96d3aa767f
7 changed files with 137 additions and 43 deletions
|
@ -55,7 +55,27 @@ class Database extends Model
|
|||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'server' => 'integer',
|
||||
'server_id' => 'integer',
|
||||
'db_server' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* Gets the host database server associated with a database.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function host()
|
||||
{
|
||||
return $this->hasOne(DatabaseServer::class, 'id', 'db_server');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server associated with a database.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function server()
|
||||
{
|
||||
return $this->hasOne(Server::class, 'id', 'server_id');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,4 +59,14 @@ class DatabaseServer extends Model
|
|||
'server_id' => 'integer',
|
||||
'db_server' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* Gets the node associated with a database host.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function node()
|
||||
{
|
||||
return $this->hasOne(Node::class, 'id', 'linked_node');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ class Node extends Model
|
|||
*/
|
||||
protected $casts = [
|
||||
'public' => 'integer',
|
||||
'location' => 'integer',
|
||||
'location_id' => 'integer',
|
||||
'memory' => 'integer',
|
||||
'disk' => 'integer',
|
||||
'daemonListen' => 'integer',
|
||||
|
@ -61,11 +61,34 @@ class Node extends Model
|
|||
];
|
||||
|
||||
/**
|
||||
* Fields that are not mass assignable.
|
||||
* Fields that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'uuidShort',
|
||||
'node_id',
|
||||
'name',
|
||||
'suspended',
|
||||
'owner_id',
|
||||
'memory',
|
||||
'swap',
|
||||
'disk',
|
||||
'io',
|
||||
'cpu',
|
||||
'oom_disabled',
|
||||
'allocation_id',
|
||||
'service_id',
|
||||
'option_id',
|
||||
'pack_id',
|
||||
'startup',
|
||||
'daemonSecret',
|
||||
'image',
|
||||
'username',
|
||||
'sftp_password',
|
||||
'installed',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
|
@ -193,4 +216,14 @@ class Node extends Model
|
|||
|
||||
return json_encode($config, $json_options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location associated with a node.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function location()
|
||||
{
|
||||
return $this->hasOne(Location::class, 'id', 'location_id');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue