2015-12-07 00:47:19 -05:00
|
|
|
<?php
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2015-12-07 00:47:19 -05:00
|
|
|
namespace Pterodactyl\Models;
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
use Carbon\Carbon;
|
|
|
|
|
use Database\Factories\LocationFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
2024-10-21 19:18:20 -06:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
2026-10-05 18:10:18 -04:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
2022-10-14 10:59:20 -06:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
|
|
|
|
|
2020-06-27 10:35:02 -07:00
|
|
|
/**
|
2021-01-27 20:52:11 -08:00
|
|
|
* @property int $id
|
|
|
|
|
* @property string $short
|
|
|
|
|
* @property string $long
|
2026-10-05 18:10:18 -04:00
|
|
|
* @property Carbon $created_at
|
|
|
|
|
* @property Carbon $updated_at
|
|
|
|
|
* @property Node[] $nodes
|
|
|
|
|
* @property Server[] $servers
|
2020-06-27 10:35:02 -07:00
|
|
|
*/
|
2026-10-05 18:10:18 -04:00
|
|
|
#[Guarded(['id', 'created_at', 'updated_at'])]
|
2020-04-03 23:22:35 -07:00
|
|
|
class Location extends Model
|
2015-12-07 00:47:19 -05:00
|
|
|
{
|
2026-10-05 18:10:18 -04:00
|
|
|
/** @use HasFactory<LocationFactory> */
|
2024-10-21 19:18:20 -06:00
|
|
|
use HasFactory;
|
|
|
|
|
|
2018-01-25 21:26:06 -06:00
|
|
|
/**
|
|
|
|
|
* The resource name for this model when it is transformed into an
|
|
|
|
|
* API representation using fractal.
|
|
|
|
|
*/
|
2026-10-05 18:10:18 -04:00
|
|
|
public const string RESOURCE_NAME = 'location';
|
2017-06-14 23:53:24 -05:00
|
|
|
|
2022-05-22 14:10:01 -04:00
|
|
|
public function getRouteKeyName(): string
|
|
|
|
|
{
|
|
|
|
|
return $this->getKeyName();
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-10 17:09:56 -05:00
|
|
|
/**
|
2018-05-13 10:50:56 -04:00
|
|
|
* Gets the nodes in a specified location.
|
2025-12-20 15:55:13 -08:00
|
|
|
*
|
2026-10-05 18:10:18 -04:00
|
|
|
* @return HasMany<Node, $this>
|
2017-02-10 17:09:56 -05:00
|
|
|
*/
|
2022-10-14 10:59:20 -06:00
|
|
|
public function nodes(): HasMany
|
2017-02-10 17:09:56 -05:00
|
|
|
{
|
|
|
|
|
return $this->hasMany(Node::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the servers within a given location.
|
2025-12-20 15:55:13 -08:00
|
|
|
*
|
2026-10-05 18:10:18 -04:00
|
|
|
* @return HasManyThrough<Server, Node, $this>
|
2017-02-10 17:09:56 -05:00
|
|
|
*/
|
2022-10-14 10:59:20 -06:00
|
|
|
public function servers(): HasManyThrough
|
2017-02-10 17:09:56 -05:00
|
|
|
{
|
|
|
|
|
return $this->hasManyThrough(Server::class, Node::class);
|
|
|
|
|
}
|
2015-12-07 00:47:19 -05:00
|
|
|
}
|