<?php12namespace Pterodactyl\Models;34use Illuminate\Validation\Rules\NotIn;5use Illuminate\Database\Eloquent\Relations\BelongsToMany;67/**8* @property int $id9* @property string $uuid10* @property string $name11* @property string $description12* @property string $source13* @property string $target14* @property bool $read_only15* @property bool $user_mountable16* @property \Pterodactyl\Models\Egg[]|\Illuminate\Database\Eloquent\Collection $eggs17* @property \Pterodactyl\Models\Node[]|\Illuminate\Database\Eloquent\Collection $nodes18* @property \Pterodactyl\Models\Server[]|\Illuminate\Database\Eloquent\Collection $servers19*/20class Mount extends Model21{22/**23* The resource name for this model when it is transformed into an24* API representation using fractal.25*/26public const RESOURCE_NAME = 'mount';2728/**29* The table associated with the model.30*/31protected $table = 'mounts';3233/**34* Fields that are not mass assignable.35*/36protected $guarded = ['id', 'uuid'];3738/**39* Default values for specific fields in the database.40*/41protected $casts = [42'id' => 'int',43'read_only' => 'bool',44'user_mountable' => 'bool',45];4647/**48* Rules verifying that the data being stored matches the expectations of the database.49*/50public static array $validationRules = [51'name' => 'required|string|min:2|max:64|unique:mounts,name',52'description' => 'nullable|string|max:191',53'source' => 'required|string',54'target' => 'required|string',55'read_only' => 'sometimes|boolean',56'user_mountable' => 'sometimes|boolean',57];5859/**60* Implement language verification by overriding Eloquence's gather61* rules function.62*/63public static function getRules(): array64{65$rules = parent::getRules();6667$rules['source'][] = new NotIn(Mount::$invalidSourcePaths);68$rules['target'][] = new NotIn(Mount::$invalidTargetPaths);6970return $rules;71}7273/**74* Disable timestamps on this model.75*/76public $timestamps = false;7778/**79* Blacklisted source paths.80*/81public static $invalidSourcePaths = [82'/etc/pterodactyl',83'/var/lib/pterodactyl/volumes',84'/srv/daemon-data',85];8687/**88* Blacklisted target paths.89*/90public static $invalidTargetPaths = [91'/home/container',92];9394/**95* Returns all eggs that have this mount assigned.96*/97public function eggs(): BelongsToMany98{99return $this->belongsToMany(Egg::class);100}101102/**103* Returns all nodes that have this mount assigned.104*/105public function nodes(): BelongsToMany106{107return $this->belongsToMany(Node::class);108}109110/**111* Returns all servers that have this mount assigned.112*/113public function servers(): BelongsToMany114{115return $this->belongsToMany(Server::class);116}117}118119120