<?php12namespace Pterodactyl\Models;34use Illuminate\Validation\Rules\NotIn;5use Pterodactyl\Contracts\Models\Identifiable;6use Pterodactyl\Models\Traits\HasRealtimeIdentifier;7use Illuminate\Database\Eloquent\Relations\BelongsToMany;89/**10* @property int $id11* @property string $uuid12* @property string $name13* @property string $description14* @property string $source15* @property string $target16* @property bool $read_only17* @property bool $user_mountable18* @property \Pterodactyl\Models\Egg[]|\Illuminate\Database\Eloquent\Collection $eggs19* @property \Pterodactyl\Models\Node[]|\Illuminate\Database\Eloquent\Collection $nodes20* @property \Pterodactyl\Models\Server[]|\Illuminate\Database\Eloquent\Collection $servers21*/22#[Attributes\Identifiable('moun')]23class Mount extends Model implements Identifiable24{25use HasRealtimeIdentifier;2627/**28* The resource name for this model when it is transformed into an29* API representation using fractal.30*/31public const RESOURCE_NAME = 'mount';3233/**34* The table associated with the model.35*/36protected $table = 'mounts';3738/**39* Fields that are not mass assignable.40*/41protected $guarded = ['id', 'uuid'];4243/**44* Default values for specific fields in the database.45*/46protected $casts = [47'id' => 'int',48'read_only' => 'bool',49'user_mountable' => 'bool',50];5152/**53* Rules verifying that the data being stored matches the expectations of the database.54*/55public static array $validationRules = [56'name' => 'required|string|min:2|max:64|unique:mounts,name',57'description' => 'nullable|string|max:191',58'source' => 'required|string',59'target' => 'required|string',60'read_only' => 'sometimes|boolean',61'user_mountable' => 'sometimes|boolean',62];6364/**65* Implement language verification by overriding Eloquence's gather66* rules function.67*/68public static function getRules(): array69{70$rules = parent::getRules();7172$rules['source'][] = new NotIn(Mount::$invalidSourcePaths);73$rules['target'][] = new NotIn(Mount::$invalidTargetPaths);7475return $rules;76}7778/**79* Disable timestamps on this model.80*/81public $timestamps = false;8283/**84* Blacklisted source paths.85*/86public static $invalidSourcePaths = [87'/etc/pterodactyl',88'/var/lib/pterodactyl/volumes',89'/srv/daemon-data',90];9192/**93* Blacklisted target paths.94*/95public static $invalidTargetPaths = [96'/home/container',97];9899/**100* Returns all eggs that have this mount assigned.101*102* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\Pterodactyl\Models\Egg, $this>103*/104public function eggs(): BelongsToMany105{106return $this->belongsToMany(Egg::class);107}108109/**110* Returns all nodes that have this mount assigned.111*112* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\Pterodactyl\Models\Node, $this>113*/114public function nodes(): BelongsToMany115{116return $this->belongsToMany(Node::class);117}118119/**120* Returns all servers that have this mount assigned.121*122* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\Pterodactyl\Models\Server, $this>123*/124public function servers(): BelongsToMany125{126return $this->belongsToMany(Server::class);127}128}129130131