Fix database management things to actually work correctly.
This commit is contained in:
parent
580e5ac569
commit
63e39fbe58
14 changed files with 124 additions and 119 deletions
|
@ -63,6 +63,11 @@ class ServersController extends Controller
|
|||
*/
|
||||
protected $databaseRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Database\CreationService
|
||||
*/
|
||||
protected $databaseCreationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface
|
||||
*/
|
||||
|
@ -97,6 +102,7 @@ class ServersController extends Controller
|
|||
AllocationRepositoryInterface $allocationRepository,
|
||||
ConfigRepository $config,
|
||||
CreationService $service,
|
||||
\Pterodactyl\Services\Database\CreationService $databaseCreationService,
|
||||
DatabaseRepositoryInterface $databaseRepository,
|
||||
DatabaseHostRepository $databaseHostRepository,
|
||||
LocationRepositoryInterface $locationRepository,
|
||||
|
@ -106,6 +112,7 @@ class ServersController extends Controller
|
|||
) {
|
||||
$this->allocationRepository = $allocationRepository;
|
||||
$this->config = $config;
|
||||
$this->databaseCreationService = $databaseCreationService;
|
||||
$this->databaseRepository = $databaseRepository;
|
||||
$this->databaseHostRepository = $databaseHostRepository;
|
||||
$this->locationRepository = $locationRepository;
|
||||
|
@ -583,20 +590,25 @@ class ServersController extends Controller
|
|||
*/
|
||||
public function newDatabase(Request $request, $id)
|
||||
{
|
||||
$repo = new DatabaseRepository;
|
||||
|
||||
try {
|
||||
$repo->create($id, $request->only(['host', 'database', 'connection']));
|
||||
|
||||
Alert::success('A new database was assigned to this server successfully.')->flash();
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('admin.servers.view.database', $id)->withInput()->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
Alert::danger('An exception occured while attempting to add a new database for this server. This error has been logged.')->flash();
|
||||
}
|
||||
$this->databaseCreationService->create($id, [
|
||||
'database' => $request->input('database'),
|
||||
'remote' => $request->input('remote'),
|
||||
'database_host_id' => $request->input('database_host_id'),
|
||||
]);
|
||||
// $repo = new DatabaseRepository;
|
||||
//
|
||||
// try {
|
||||
// $repo->create($id, $request->only(['host', 'database', 'connection']));
|
||||
//
|
||||
// Alert::success('A new database was assigned to this server successfully.')->flash();
|
||||
// } catch (DisplayValidationException $ex) {
|
||||
// return redirect()->route('admin.servers.view.database', $id)->withInput()->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
// } catch (DisplayException $ex) {
|
||||
// Alert::danger($ex->getMessage())->flash();
|
||||
// } catch (\Exception $ex) {
|
||||
// Log::error($ex);
|
||||
// Alert::danger('An exception occured while attempting to add a new database for this server. This error has been logged.')->flash();
|
||||
// }
|
||||
|
||||
return redirect()->route('admin.servers.view.database', $id)->withInput();
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ use Illuminate\Http\Request;
|
|||
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
||||
use Pterodactyl\Models\User;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Pterodactyl\Services\Administrative\UserService;
|
||||
use Pterodactyl\Services\UserService;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Http\Requests\Admin\UserFormRequest;
|
||||
|
@ -41,7 +41,7 @@ class UserController extends Controller
|
|||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Administrative\UserService
|
||||
* @var \Pterodactyl\Services\UserService
|
||||
*/
|
||||
protected $service;
|
||||
|
||||
|
@ -59,7 +59,7 @@ class UserController extends Controller
|
|||
* UserController constructor.
|
||||
*
|
||||
* @param \Prologue\Alerts\AlertsMessageBag $alert
|
||||
* @param \Pterodactyl\Services\Administrative\UserService $service
|
||||
* @param \Pterodactyl\Services\UserService $service
|
||||
* @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository
|
||||
* @param \Pterodactyl\Models\User $model
|
||||
*/
|
||||
|
@ -178,17 +178,11 @@ class UserController extends Controller
|
|||
/**
|
||||
* Get a JSON response of users on the system.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Pterodactyl\Models\User
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public function json(Request $request)
|
||||
{
|
||||
return $this->model->search($request->input('q'))->all([
|
||||
'id', 'email', 'username', 'name_first', 'name_last',
|
||||
])->transform(function ($item) {
|
||||
$item->md5 = md5(strtolower($item->email));
|
||||
|
||||
return $item;
|
||||
});
|
||||
return $this->repository->filterUsersByQuery($request->input('q'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue