Skip to content

Commit abd60ee

Browse files
committed
Fix 500 error when mounting a mount and fix the actual mount being deleted instead of the relation
1 parent d795668 commit abd60ee

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

app/Http/Controllers/Admin/ServersController.php

Lines changed: 11 additions & 9 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,21 @@ 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([
429+
/*$server->mounts()->updateOrCreate([
430430
'mount_id' => $mount->id,
431431
'server_id' => $server->id,
432-
]);
432+
]);*/
433+
434+
$mountServer = new MountServer;
435+
$mountServer->mount_id = $mount->id;
436+
$mountServer->server_id = $server->id;
437+
$mountServer->saveOrFail();
433438

434439
$data = $this->serverConfigurationStructureService->handle($server);
435440

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

466468
$data = $this->serverConfigurationStructureService->handle($server);
467469

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)