2015-12-07 05:47:19 +00:00
|
|
|
<?php
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2015-12-07 05:47:19 +00:00
|
|
|
namespace Pterodactyl\Models;
|
|
|
|
|
2020-06-27 17:35:02 +00:00
|
|
|
/**
|
2021-01-23 20:33:34 +00:00
|
|
|
* @property int $id
|
|
|
|
* @property string $short
|
|
|
|
* @property string $long
|
|
|
|
* @property \Carbon\Carbon $created_at
|
|
|
|
* @property \Carbon\Carbon $updated_at
|
|
|
|
* @property \Pterodactyl\Models\Node[] $nodes
|
2020-06-27 17:35:02 +00:00
|
|
|
* @property \Pterodactyl\Models\Server[] $servers
|
|
|
|
*/
|
2020-04-04 06:22:35 +00:00
|
|
|
class Location extends Model
|
2015-12-07 05:47:19 +00:00
|
|
|
{
|
2018-01-26 03:26:06 +00:00
|
|
|
/**
|
|
|
|
* The resource name for this model when it is transformed into an
|
|
|
|
* API representation using fractal.
|
|
|
|
*/
|
2021-01-23 20:33:34 +00:00
|
|
|
public const RESOURCE_NAME = 'location';
|
2018-01-26 03:26:06 +00:00
|
|
|
|
2015-12-07 05:47:19 +00:00
|
|
|
/**
|
|
|
|
* The table associated with the model.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $table = 'locations';
|
|
|
|
|
2016-01-17 04:10:46 +00:00
|
|
|
/**
|
|
|
|
* Fields that are not mass assignable.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $guarded = ['id', 'created_at', 'updated_at'];
|
2017-02-10 22:09:56 +00:00
|
|
|
|
2017-06-25 00:49:09 +00:00
|
|
|
/**
|
|
|
|
* Rules ensuring that the raw data stored in the database meets expectations.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2019-09-05 05:19:57 +00:00
|
|
|
public static $validationRules = [
|
|
|
|
'short' => 'required|string|between:1,60|unique:locations,short',
|
2020-09-26 23:29:26 +00:00
|
|
|
'long' => 'string|nullable|between:1,191',
|
2017-06-15 04:53:24 +00:00
|
|
|
];
|
|
|
|
|
2017-02-10 22:09:56 +00:00
|
|
|
/**
|
2018-05-13 14:50:56 +00:00
|
|
|
* Gets the nodes in a specified location.
|
2017-02-10 22:09:56 +00:00
|
|
|
*
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
*/
|
|
|
|
public function nodes()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Node::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the servers within a given location.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
|
|
|
*/
|
|
|
|
public function servers()
|
|
|
|
{
|
|
|
|
return $this->hasManyThrough(Server::class, Node::class);
|
|
|
|
}
|
2015-12-07 05:47:19 +00:00
|
|
|
}
|