Skip to content

Commit 289de72

Browse files
authored
Merge pull request pterodactyl#2497 from pterodactyl/fix/server-mounts
Fix server mounts
2 parents 1ad8b3f + 3ef3c2a commit 289de72

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

app/Http/Controllers/Admin/ServersController.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Pterodactyl\Models\User;
1515
use Pterodactyl\Models\Mount;
1616
use Pterodactyl\Models\Server;
17+
use Pterodactyl\Models\MountServer;
1718
use Prologue\Alerts\AlertsMessageBag;
1819
use GuzzleHttp\Exception\RequestException;
1920
use Pterodactyl\Exceptions\DisplayException;
@@ -419,17 +420,16 @@ public function deleteDatabase($server, $database)
419420
*
420421
* @param Server $server
421422
* @param \Pterodactyl\Models\Mount $mount
422-
* @return \Illuminate\Http\RedirectResponse
423423
*
424-
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
425-
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
424+
* @return \Illuminate\Http\RedirectResponse
425+
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException|\Throwable
426426
*/
427427
public function addMount(Server $server, Mount $mount)
428428
{
429-
$server->mounts()->updateOrCreate([
430-
'mount_id' => $mount->id,
431-
'server_id' => $server->id,
432-
]);
429+
$mountServer = new MountServer;
430+
$mountServer->mount_id = $mount->id;
431+
$mountServer->server_id = $server->id;
432+
$mountServer->saveOrFail();
433433

434434
$data = $this->serverConfigurationStructureService->handle($server);
435435

@@ -458,10 +458,7 @@ public function addMount(Server $server, Mount $mount)
458458
*/
459459
public function deleteMount(Server $server, Mount $mount)
460460
{
461-
$server->mounts()
462-
->where('mount_id', $mount->id)
463-
->where('server_id', $server->id)
464-
->delete();
461+
MountServer::where('mount_id', $mount->id)->where('server_id', $server->id)->delete();
465462

466463
$data = $this->serverConfigurationStructureService->handle($server);
467464

app/Models/MountServer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ class MountServer extends Model
1111
*/
1212
protected $table = 'mount_server';
1313

14+
/**
15+
* @var bool
16+
*/
17+
public $timestamps = false;
18+
1419
/**
1520
* @var null
1621
*/

0 commit comments

Comments
 (0)