*/ use HasFactory; use HasRealtimeIdentifier; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ public const string RESOURCE_NAME = 'mount'; /** * Blacklisted source paths. * * @var list */ public static array $invalidSourcePaths = [ '/etc/pterodactyl', '/var/lib/pterodactyl/volumes', '/srv/daemon-data', ]; /** * Blacklisted target paths. * * @var list */ public static array $invalidTargetPaths = [ '/home/container', ]; /** * @return array */ protected function casts(): array { return [ 'id' => 'int', 'read_only' => 'bool', 'user_mountable' => 'bool', ]; } /** * Returns all eggs that have this mount assigned. * * @return BelongsToMany */ public function eggs(): BelongsToMany { return $this->belongsToMany(Egg::class); } /** * Returns all nodes that have this mount assigned. * * @return BelongsToMany */ public function nodes(): BelongsToMany { return $this->belongsToMany(Node::class); } /** * Returns all servers that have this mount assigned. * * @return BelongsToMany */ public function servers(): BelongsToMany { return $this->belongsToMany(Server::class); } /** * Mounts attached to both the server's egg and its node, whether or not the * server currently has them mounted. * * @param Builder $query */ #[Scope] protected function availableToServer(Builder $query, Server $server): void { $query ->whereHas('eggs', fn (Builder $eggs) => $eggs->whereKey($server->egg_id)) ->whereHas('nodes', fn (Builder $nodes) => $nodes->whereKey($server->node_id)); } }