|
@@ -22,26 +22,16 @@ use Illuminate\Support\Facades\Auth;
|
|
|
|
|
|
class ServerController extends Controller
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * Display a listing of the resource.
|
|
|
- *
|
|
|
- * @return Factory|View
|
|
|
- */
|
|
|
- public function index()
|
|
|
+ /** Display a listing of the resource. */
|
|
|
+ public function index(): View|Factory
|
|
|
{
|
|
|
return view('servers.index')->with([
|
|
|
'servers' => Auth::user()->Servers
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Show the form for creating a new resource.
|
|
|
- *
|
|
|
- * @return Factory|View|RedirectResponse
|
|
|
- */
|
|
|
- public function create()
|
|
|
+ /** Show the form for creating a new resource. */
|
|
|
+ public function create(): View|Factory|RedirectResponse
|
|
|
{
|
|
|
//limit
|
|
|
if (Auth::user()->Servers->count() >= Auth::user()->server_limit) {
|
|
@@ -63,13 +53,8 @@ class ServerController extends Controller
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Store a newly created resource in storage.
|
|
|
- *
|
|
|
- * @param Request $request
|
|
|
- * @return RedirectResponse
|
|
|
- */
|
|
|
- public function store(Request $request)
|
|
|
+ /** Store a newly created resource in storage. */
|
|
|
+ public function store(Request $request): RedirectResponse
|
|
|
{
|
|
|
$request->validate([
|
|
|
"name" => "required|max:191",
|
|
@@ -89,7 +74,6 @@ class ServerController extends Controller
|
|
|
return redirect()->route('servers.index')->with('error', "You do not have the required amount of credits to create a new server!");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//create server
|
|
|
$egg = Egg::findOrFail($request->input('egg_id'));
|
|
|
$server = Auth::user()->servers()->create($request->all());
|
|
@@ -110,11 +94,7 @@ class ServerController extends Controller
|
|
|
return redirect()->route('servers.index')->with('success', 'server created');
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Quick Fix
|
|
|
- * @param Server $server
|
|
|
- * @return RedirectResponse
|
|
|
- */
|
|
|
+ /** Quick Fix */
|
|
|
private function serverCreationFailed(Server $server): RedirectResponse
|
|
|
{
|
|
|
$server->delete();
|
|
@@ -123,51 +103,14 @@ class ServerController extends Controller
|
|
|
return redirect()->route('servers.index')->with('error', 'No allocations satisfying the requirements for automatic deployment were found.');
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Display the specified resource.
|
|
|
- *
|
|
|
- * @param Server $server
|
|
|
- * @return Response
|
|
|
- */
|
|
|
- public function show(Server $server)
|
|
|
- {
|
|
|
- //
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Show the form for editing the specified resource.
|
|
|
- *
|
|
|
- * @param Server $server
|
|
|
- * @return Response
|
|
|
- */
|
|
|
- public function edit(Server $server)
|
|
|
+ /** Remove the specified resource from storage. */
|
|
|
+ public function destroy(Server $server): RedirectResponse
|
|
|
{
|
|
|
- //
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Update the specified resource in storage.
|
|
|
- *
|
|
|
- * @param Request $request
|
|
|
- * @param Server $server
|
|
|
- * @return Response
|
|
|
- */
|
|
|
- public function update(Request $request, Server $server)
|
|
|
- {
|
|
|
- //
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Remove the specified resource from storage.
|
|
|
- *
|
|
|
- * @param Server $server
|
|
|
- * @return RedirectResponse
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public function destroy(Server $server)
|
|
|
- {
|
|
|
- $server->delete();
|
|
|
-
|
|
|
- return redirect()->route('servers.index')->with('success', 'server removed');
|
|
|
+ try {
|
|
|
+ $server->delete();
|
|
|
+ return redirect()->route('servers.index')->with('success', 'server removed');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return redirect()->route('servers.index')->with('error', 'An exception has occurred while trying to remove a resource');
|
|
|
+ }
|
|
|
}
|
|
|
}
|