Files
pterodactyl-panel/app/Models/Location.php
T

60 lines
1.4 KiB
PHP
Raw Normal View History

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
/**
* @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'])]
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;
/**
* 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';
2022-05-22 14:10:01 -04:00
public function getRouteKeyName(): string
{
return $this->getKeyName();
}
/**
2018-05-13 10:50:56 -04:00
* Gets the nodes in a specified location.
*
2026-10-05 18:10:18 -04:00
* @return HasMany<Node, $this>
*/
2022-10-14 10:59:20 -06:00
public function nodes(): HasMany
{
return $this->hasMany(Node::class);
}
/**
* Gets the servers within a given location.
*
2026-10-05 18:10:18 -04:00
* @return HasManyThrough<Server, Node, $this>
*/
2022-10-14 10:59:20 -06:00
public function servers(): HasManyThrough
{
return $this->hasManyThrough(Server::class, Node::class);
}
2015-12-07 00:47:19 -05:00
}