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

74 lines
1.8 KiB
PHP
Raw Normal View History

2016-02-08 18:03:02 -05:00
<?php
2016-12-07 22:46:38 +00:00
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
2016-02-08 18:03:02 -05:00
namespace Pterodactyl\Models;
2026-10-05 18:10:18 -04:00
use Carbon\CarbonImmutable;
use Database\Factories\DatabaseHostFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Hidden;
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\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
2022-10-14 10:59:20 -06:00
2021-01-23 12:09:16 -08:00
/**
* @property int $id
* @property string $name
* @property string $host
* @property int $port
* @property string $username
* @property string $password
* @property int|null $max_databases
* @property int|null $node_id
2026-10-05 18:10:18 -04:00
* @property CarbonImmutable $created_at
* @property CarbonImmutable $updated_at
2021-01-23 12:09:16 -08:00
*/
2026-10-05 18:10:18 -04:00
#[Fillable([
'name', 'host', 'port', 'username', 'password', 'max_databases', 'node_id',
])]
#[Hidden(['password'])]
class DatabaseHost extends Model
2016-02-08 18:03:02 -05:00
{
2026-10-05 18:10:18 -04:00
/** @use HasFactory<DatabaseHostFactory> */
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 = 'database_host';
2016-02-08 18:03:02 -05:00
2017-03-19 19:36:50 -04:00
/**
2026-10-05 18:10:18 -04:00
* @return array<string, string>
2017-03-19 19:36:50 -04:00
*/
2026-10-05 18:10:18 -04:00
protected function casts(): array
{
return [
'id' => 'integer',
'max_databases' => 'integer',
'node_id' => 'integer',
];
}
2017-03-19 19:36:50 -04:00
/**
* Gets the node associated with a database host.
*
2026-10-05 18:10:18 -04:00
* @return BelongsTo<Node, $this>
2017-03-19 19:36:50 -04:00
*/
2022-10-14 10:59:20 -06:00
public function node(): BelongsTo
2017-03-19 19:36:50 -04:00
{
return $this->belongsTo(Node::class);
}
2017-03-19 19:36:50 -04:00
/**
2018-05-13 10:50:56 -04:00
* Gets the databases associated with this host.
*
2026-10-05 18:10:18 -04:00
* @return HasMany<Database, $this>
2017-03-19 19:36:50 -04:00
*/
2022-10-14 10:59:20 -06:00
public function databases(): HasMany
2017-03-19 19:36:50 -04:00
{
return $this->hasMany(Database::class);
}
2016-02-08 18:03:02 -05:00
}