PteroTheme/app/Http/Controllers/Admin/MountController.php

74 lines
2.0 KiB
PHP
Raw Normal View History

2020-05-21 00:29:03 +01:00
<?php
2020-05-21 01:55:59 +01:00
namespace Pterodactyl\Http\Controllers\Admin;
2020-05-21 00:29:03 +01:00
2020-05-21 01:55:59 +01:00
use Prologue\Alerts\AlertsMessageBag;
2020-05-21 00:29:03 +01:00
use Pterodactyl\Http\Controllers\Controller;
2020-05-21 01:55:59 +01:00
use Pterodactyl\Http\Requests\Admin\MountFormRequest;
use Pterodactyl\Repositories\Eloquent\MountRepository;
2020-05-21 01:55:59 +01:00
use Pterodactyl\Services\Mounts\MountCreationService;
2020-05-21 00:29:03 +01:00
class MountController extends Controller
{
2020-05-21 01:55:59 +01:00
/**
* @var \Prologue\Alerts\AlertsMessageBag
*/
protected $alert;
2020-05-21 00:29:03 +01:00
/**
* @var \Pterodactyl\Repositories\Eloquent\MountRepository
2020-05-21 00:29:03 +01:00
*/
protected $repository;
2020-05-21 01:55:59 +01:00
/**
* @var \Pterodactyl\Services\Locations\LocationCreationService
*/
protected $creationService;
2020-05-21 00:29:03 +01:00
/**
* MountController constructor.
2020-05-21 00:29:03 +01:00
*
2020-05-21 01:55:59 +01:00
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Repositories\Eloquent\MountRepository $repository
2020-05-21 01:55:59 +01:00
* @param \Pterodactyl\Services\Mounts\MountCreationService $creationService
2020-05-21 00:29:03 +01:00
*/
public function __construct(
2020-05-21 01:55:59 +01:00
AlertsMessageBag $alert,
MountRepository $repository,
MountCreationService $creationService
2020-05-21 00:29:03 +01:00
) {
2020-05-21 01:55:59 +01:00
$this->alert = $alert;
2020-05-21 00:29:03 +01:00
$this->repository = $repository;
2020-05-21 01:55:59 +01:00
$this->creationService = $creationService;
2020-05-21 00:29:03 +01:00
}
/**
* Return the mount overview page.
*
* @return \Illuminate\View\View
*/
public function index()
{
return view('admin.mounts.index', [
'mounts' => $this->repository->getAllWithDetails(),
2020-05-21 00:29:03 +01:00
]);
}
2020-05-21 01:55:59 +01:00
/**
* Handle request to create new mount.
*
* @param \Pterodactyl\Http\Requests\Admin\MountFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
*/
public function create(MountFormRequest $request)
{
$mount = $this->creationService->handle($request->normalize());
$this->alert->success('Mount was created successfully.')->flash();
//return redirect()->route('admin.mounts.view', $mount->id);
return redirect()->route('admin.mounts');
}
2020-05-21 00:29:03 +01:00
}