2026-10-05 18:10:18 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace Pterodactyl\Actions\Servers;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|
|
|
|
use Pterodactyl\Contracts\Servers\AttachesMountsToServers;
|
|
|
|
|
use Pterodactyl\Models\Mount;
|
|
|
|
|
use Pterodactyl\Models\MountServer;
|
|
|
|
|
use Pterodactyl\Models\Server;
|
|
|
|
|
|
|
|
|
|
final class AttachMountToServer implements AttachesMountsToServers
|
|
|
|
|
{
|
|
|
|
|
public function attach(Server $server, int $mountId): Mount
|
|
|
|
|
{
|
|
|
|
|
$mount = Mount::query()->availableToServer($server)->whereKey($mountId)->first();
|
|
|
|
|
if ($mount === null) {
|
|
|
|
|
throw (new ModelNotFoundException)->setModel(Mount::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(new MountServer)->forceFill(['mount_id' => $mount->id, 'server_id' => $server->id])->saveOrFail();
|
|
|
|
|
|
2026-10-08 17:40:00 -04:00
|
|
|
return $mount;
|
2026-10-05 18:10:18 -04:00
|
|
|
}
|
|
|
|
|
}
|