<?php12namespace Pterodactyl\Models;34use Illuminate\Database\Eloquent\Relations\HasMany;5use Illuminate\Database\Eloquent\Relations\BelongsTo;6use Illuminate\Database\Eloquent\Factories\HasFactory;78/**9* @property int $id10* @property string $name11* @property string $host12* @property int $port13* @property string $username14* @property string $password15* @property int|null $max_databases16* @property int|null $node_id17* @property \Carbon\CarbonImmutable $created_at18* @property \Carbon\CarbonImmutable $updated_at19*/20class DatabaseHost extends Model21{22/** @use HasFactory<\Database\Factories\DatabaseHostFactory> */23use HasFactory;2425/**26* The resource name for this model when it is transformed into an27* API representation using fractal.28*/29public const RESOURCE_NAME = 'database_host';3031protected bool $immutableDates = true;3233/**34* The table associated with the model.35*/36protected $table = 'database_hosts';3738/**39* The attributes excluded from the model's JSON form.40*/41protected $hidden = ['password'];4243/**44* Fields that are mass assignable.45*/46protected $fillable = [47'name', 'host', 'port', 'username', 'password', 'max_databases', 'node_id',48];4950/**51* Cast values to correct type.52*/53protected $casts = [54'id' => 'integer',55'max_databases' => 'integer',56'node_id' => 'integer',57];5859/**60* Validation rules to assign to this model.61*/62public static array $validationRules = [63'name' => 'required|string|max:191',64'host' => 'required|string',65'port' => 'required|numeric|between:1,65535',66'username' => 'required|string|max:32',67'password' => 'nullable|string',68'node_id' => 'sometimes|nullable|integer|exists:nodes,id',69];7071/**72* Gets the node associated with a database host.73*/74public function node(): BelongsTo75{76return $this->belongsTo(Node::class);77}7879/**80* Gets the databases associated with this host.81*/82public function databases(): HasMany83{84return $this->hasMany(Database::class);85}86}878889