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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue