Cleaned up controllers with for PHP 8
Cleaned up controllers with for PHP 8
This commit is contained in:
commit
1ae9d110c4
5 changed files with 28 additions and 292 deletions
|
@ -2,28 +2,19 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
/** Show the application dashboard. */
|
||||
public function index(Request $request): Renderable
|
||||
{
|
||||
//set cookie as extra layer of defense against users that make multiple accounts
|
||||
setcookie('4b3403665fea6' , base64_encode(1) , time() + (20 * 365 * 24 * 60 * 60));
|
||||
|
|
|
@ -11,12 +11,8 @@ use Illuminate\Support\Facades\Auth;
|
|||
|
||||
class NotificationController 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
|
||||
{
|
||||
$notifications = Auth::user()->notifications()->paginate();
|
||||
|
||||
|
@ -25,34 +21,8 @@ class NotificationController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param string $id
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function show($id)
|
||||
/** Display the specified resource. */
|
||||
public function show(string $id): View|Factory
|
||||
{
|
||||
$notification = Auth::user()->notifications()->findOrFail($id);
|
||||
|
||||
|
@ -61,38 +31,4 @@ class NotificationController extends Controller
|
|||
'notification' => $notification
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,12 +14,8 @@ use Illuminate\Support\Facades\Hash;
|
|||
|
||||
class ProfileController 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('profile.index')->with([
|
||||
'user' => Auth::user(),
|
||||
|
@ -28,57 +24,8 @@ class ProfileController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function update(Request $request, int $id)
|
||||
/** Update the specified resource in storage. */
|
||||
public function update(Request $request, int $id): RedirectResponse
|
||||
{
|
||||
//prevent other users from editing a user
|
||||
if ($id != Auth::user()->id) dd(401);
|
||||
|
@ -136,15 +83,4 @@ class ProfileController extends Controller
|
|||
|
||||
return redirect()->route('profile.index')->with('success' , 'profile updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
/** Remove the specified resource from storage. */
|
||||
public function destroy(Server $server): RedirectResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param Server $server
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Server $server)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,8 @@ use Illuminate\Http\Response;
|
|||
|
||||
class StoreController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return Application|Factory|View|Response
|
||||
*/
|
||||
public function index()
|
||||
/** Display a listing of the resource. */
|
||||
public function index(): View|Factory|Response|Application
|
||||
{
|
||||
$isPaypalSetup = false;
|
||||
if (env('PAYPAL_SECRET') && env('PAYPAL_CLIENT_ID')) $isPaypalSetup = true;
|
||||
|
@ -26,70 +22,4 @@ class StoreController extends Controller
|
|||
'isPaypalSetup' => $isPaypalSetup
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue