2020-05-21 01:29:03 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Models;
|
|
|
|
|
|
|
|
/**
|
2020-05-21 03:11:20 +02:00
|
|
|
* @property int $id
|
|
|
|
* @property string $uuid
|
2020-05-21 02:00:53 +02:00
|
|
|
* @property string $name
|
|
|
|
* @property string $description
|
|
|
|
* @property string $source
|
|
|
|
* @property string $target
|
|
|
|
* @property bool $read_only
|
|
|
|
* @property bool $user_mountable
|
|
|
|
*
|
2020-05-21 22:23:12 +02:00
|
|
|
* @property \Pterodactyl\Models\Egg[]|\Illuminate\Database\Eloquent\Collection $eggs
|
|
|
|
* @property \Pterodactyl\Models\Node[]|\Illuminate\Database\Eloquent\Collection $nodes
|
|
|
|
* @property \Pterodactyl\Models\Server[]|\Illuminate\Database\Eloquent\Collection $servers
|
2020-05-21 01:29:03 +02:00
|
|
|
*/
|
|
|
|
class Mount extends Model
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The resource name for this model when it is transformed into an
|
|
|
|
* API representation using fractal.
|
|
|
|
*/
|
|
|
|
const RESOURCE_NAME = 'mount';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The table associated with the model.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $table = 'mounts';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fields that are not mass assignable.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2020-05-21 03:11:20 +02:00
|
|
|
protected $guarded = ['id', 'uuid', 'name', 'description', 'source', 'target'];
|
2020-05-21 02:00:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Default values for specific fields in the database.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $attributes = [
|
2020-05-21 03:11:20 +02:00
|
|
|
'id' => 'int',
|
|
|
|
'uuid' => 'string',
|
|
|
|
'name' => 'string',
|
|
|
|
'description' => 'string',
|
|
|
|
'source' => 'string',
|
|
|
|
'target' => 'string',
|
2020-05-21 02:00:53 +02:00
|
|
|
'read_only' => 'bool',
|
|
|
|
'user_mountable' => 'bool',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rules verifying that the data being stored matches the expectations of the database.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public static $validationRules = [
|
2020-05-21 03:11:20 +02:00
|
|
|
// 'uuid' => 'required|string|size:36|unique:mounts,uuid',
|
2020-05-21 02:00:53 +02:00
|
|
|
'name' => 'required|string|min:2|max:64|unique:mounts,name',
|
|
|
|
'description' => 'nullable|string|max:255',
|
|
|
|
'source' => 'required|string',
|
|
|
|
'target' => 'required|string',
|
|
|
|
'read_only' => 'sometimes|boolean',
|
|
|
|
'user_mountable' => 'sometimes|boolean',
|
|
|
|
];
|
|
|
|
|
2020-05-21 02:55:59 +02:00
|
|
|
/**
|
|
|
|
* Disable timestamps on this model.
|
2020-05-21 02:57:30 +02:00
|
|
|
*
|
2020-05-21 02:55:59 +02:00
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
public $timestamps = false;
|
|
|
|
|
2020-05-21 02:00:53 +02:00
|
|
|
/**
|
|
|
|
* Returns all eggs that have this mount assigned.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
|
|
*/
|
|
|
|
public function eggs()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany(Egg::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns all nodes that have this mount assigned.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
|
|
*/
|
|
|
|
public function nodes()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany(Node::class);
|
|
|
|
}
|
2020-05-21 22:23:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns all servers that have this mount assigned.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
|
|
*/
|
|
|
|
public function servers()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany(Server::class);
|
|
|
|
}
|
2020-05-21 01:29:03 +02:00
|
|
|
}
|