Merge pull request #158 from ControlPanel-gg/server_delete
fixed a bug: is ptero is down don't delete the server from our side
This commit is contained in:
commit
692aee69ef
|
@ -90,8 +90,12 @@ class ServerController extends Controller
|
||||||
*/
|
*/
|
||||||
public function destroy(Server $server)
|
public function destroy(Server $server)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
$server->delete();
|
$server->delete();
|
||||||
return redirect()->back()->with('success', 'server has been removed!');
|
return redirect()->route('admin.servers.index')->with('success', 'server removed');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()->route('admin.servers.index')->with('error', 'An exception has occurred while trying to remove a resource "' . $e->getMessage() . '"');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -111,7 +111,7 @@ class ServerController extends Controller
|
||||||
$server->delete();
|
$server->delete();
|
||||||
return redirect()->route('servers.index')->with('success', 'server removed');
|
return redirect()->route('servers.index')->with('success', 'server removed');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return redirect()->route('servers.index')->with('error', 'An exception has occurred while trying to remove a resource');
|
return redirect()->route('servers.index')->with('error', 'An exception has occurred while trying to remove a resource "' . $e->getMessage() . '"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,8 @@ class Server extends Model
|
||||||
});
|
});
|
||||||
|
|
||||||
static::deleting(function (Server $server) {
|
static::deleting(function (Server $server) {
|
||||||
Pterodactyl::client()->delete("/application/servers/{$server->pterodactyl_id}");
|
$response = Pterodactyl::client()->delete("/application/servers/{$server->pterodactyl_id}");
|
||||||
|
if ($response->failed()) throw new Exception($response['errors'][0]['code']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue