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 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
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
#[Fillable([
|
|
|
|
|
'name', 'host', 'port', 'username', 'password', 'max_databases', 'node_id',
|
|
|
|
|
])]
|
|
|
|
|
#[Hidden(['password'])]
|
2020-04-03 23:22:35 -07:00
|
|
|
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;
|
|
|
|
|
|
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',
|
2026-10-11 23:41:04 -04:00
|
|
|
'port' => 'integer',
|
2026-10-05 18:10:18 -04:00
|
|
|
'max_databases' => 'integer',
|
|
|
|
|
'node_id' => 'integer',
|
|
|
|
|
];
|
|
|
|
|
}
|
2017-04-13 23:19:01 -04:00
|
|
|
|
2017-03-19 19:36:50 -04:00
|
|
|
/**
|
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-02-09 17:43:54 -05:00
|
|
|
|
2017-03-19 19:36:50 -04:00
|
|
|
/**
|
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
|
|
|
{
|
2026-10-13 21:07:43 -04:00
|
|
|
return $this->hasMany(Database::class)->orderBy('id');
|
2017-03-19 19:36:50 -04:00
|
|
|
}
|
2016-02-08 18:03:02 -05:00
|
|
|
}
|