2015-12-07 06:47:19 +01:00
|
|
|
<?php
|
2016-12-07 23:46:38 +01:00
|
|
|
|
2015-12-07 06:47:19 +01:00
|
|
|
namespace Pterodactyl\Models;
|
|
|
|
|
2020-06-27 19:35:02 +02: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
|
|
|
|
* @property \Pterodactyl\Models\Server[] $servers
|
|
|
|
*/
|
2020-04-04 08:22:35 +02:00
|
|
|
class Location extends Model
|
2015-12-07 06:47:19 +01:00
|
|
|
{
|
2018-01-26 04:26:06 +01:00
|
|
|
/**
|
|
|
|
* The resource name for this model when it is transformed into an
|
|
|
|
* API representation using fractal.
|
|
|
|
*/
|
|
|
|
const RESOURCE_NAME = 'location';
|
|
|
|
|
2015-12-07 06:47:19 +01:00
|
|
|
/**
|
|
|
|
* The table associated with the model.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $table = 'locations';
|
|
|
|
|
2016-01-17 05:10:46 +01:00
|
|
|
/**
|
|
|
|
* Fields that are not mass assignable.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $guarded = ['id', 'created_at', 'updated_at'];
|
2017-02-10 23:09:56 +01:00
|
|
|
|
2017-06-25 02:49:09 +02:00
|
|
|
/**
|
|
|
|
* Rules ensuring that the raw data stored in the database meets expectations.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2019-09-05 07:19:57 +02:00
|
|
|
public static $validationRules = [
|
|
|
|
'short' => 'required|string|between:1,60|unique:locations,short',
|
2020-04-18 02:52:40 +02:00
|
|
|
'long' => 'string|nullable|between:1,255',
|
2017-06-15 06:53:24 +02:00
|
|
|
];
|
|
|
|
|
2017-02-10 23:09:56 +01:00
|
|
|
/**
|
2018-05-13 16:50:56 +02:00
|
|
|
* Gets the nodes in a specified location.
|
2017-02-10 23:09:56 +01: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 06:47:19 +01:00
|
|
|
}
|