Replace egg repository

This commit is contained in:
Lance Pioch 2022-10-23 17:27:18 -04:00
parent 860b2d890b
commit 6e4f7f16c1
11 changed files with 54 additions and 206 deletions

View file

@ -13,7 +13,6 @@ use Pterodactyl\Services\Eggs\EggUpdateService;
use Pterodactyl\Services\Eggs\EggCreationService;
use Pterodactyl\Services\Eggs\EggDeletionService;
use Pterodactyl\Http\Requests\Admin\Egg\EggFormRequest;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
class EggController extends Controller
@ -25,7 +24,6 @@ class EggController extends Controller
protected AlertsMessageBag $alert,
protected EggCreationService $creationService,
protected EggDeletionService $deletionService,
protected EggRepositoryInterface $repository,
protected EggUpdateService $updateService,
protected NestRepositoryInterface $nestRepository,
protected ViewFactory $view

View file

@ -9,7 +9,6 @@ use Prologue\Alerts\AlertsMessageBag;
use Illuminate\View\Factory as ViewFactory;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\Eggs\Scripts\InstallScriptService;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Http\Requests\Admin\Egg\EggScriptFormRequest;
class EggScriptController extends Controller
@ -19,7 +18,6 @@ class EggScriptController extends Controller
*/
public function __construct(
protected AlertsMessageBag $alert,
protected EggRepositoryInterface $repository,
protected InstallScriptService $installScriptService,
protected ViewFactory $view
) {
@ -30,16 +28,17 @@ class EggScriptController extends Controller
*/
public function index(int $egg): View
{
$egg = $this->repository->getWithCopyAttributes($egg);
$copy = $this->repository->findWhere([
['copy_script_from', '=', null],
['nest_id', '=', $egg->nest_id],
['id', '!=', $egg],
]);
$egg = Egg::with('scriptFrom', 'configFrom')
->where('id', $egg)
->firstOrFail();
$rely = $this->repository->findWhere([
['copy_script_from', '=', $egg->id],
]);
$copy = Egg::query()
->whereNull('copy_script_from')
->where('nest_id', $egg->nest_id)
->whereNot('id', $egg->id)
->firstOrFail();
$rely = Egg::query()->where('copy_script_from', $egg->id)->firstOrFail();
return $this->view->make('admin.eggs.scripts', [
'copyFromOptions' => $copy,

View file

@ -9,7 +9,6 @@ use Illuminate\Http\RedirectResponse;
use Prologue\Alerts\AlertsMessageBag;
use Illuminate\View\Factory as ViewFactory;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Services\Eggs\Variables\VariableUpdateService;
use Pterodactyl\Http\Requests\Admin\Egg\EggVariableFormRequest;
use Pterodactyl\Services\Eggs\Variables\VariableCreationService;
@ -24,7 +23,6 @@ class EggVariableController extends Controller
protected AlertsMessageBag $alert,
protected VariableCreationService $creationService,
protected VariableUpdateService $updateService,
protected EggRepositoryInterface $repository,
protected EggVariableRepositoryInterface $variableRepository,
protected ViewFactory $view
) {
@ -33,11 +31,10 @@ class EggVariableController extends Controller
/**
* Handle request to view the variables attached to an Egg.
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function view(int $egg): View
{
$egg = $this->repository->getWithVariables($egg);
$egg = Egg::with('variables')->findOrFail($egg);
return $this->view->make('admin.eggs.variables', ['egg' => $egg]);
}