ptero settings in DB, phpmyadmin in db
This commit is contained in:
parent
e959cc79cb
commit
b9d5f83652
8 changed files with 84 additions and 30 deletions
|
@ -27,10 +27,10 @@ class Pterodactyl
|
|||
public static function client()
|
||||
{
|
||||
return Http::withHeaders([
|
||||
'Authorization' => 'Bearer ' . env('PTERODACTYL_TOKEN', false),
|
||||
'Authorization' => 'Bearer ' . Settings::getValueByKey("SETTINGS::SYSTEM:PTERODACTYL:TOKEN"),
|
||||
'Content-type' => 'application/json',
|
||||
'Accept' => 'Application/vnd.pterodactyl.v1+json',
|
||||
])->baseUrl(env('PTERODACTYL_URL') . '/api');
|
||||
])->baseUrl(Settings::getValueByKey("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/api');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,7 +158,7 @@ class Pterodactyl
|
|||
*/
|
||||
public static function url(string $route): string
|
||||
{
|
||||
return env('PTERODACTYL_URL') . $route;
|
||||
return Settings::getValueByKey("SETTINGS::SYSTEM:PTERODACTYL:URL") . $route;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
57
app/Classes/Settings/Misc.php
Normal file
57
app/Classes/Settings/Misc.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace App\Classes\Settings;
|
||||
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
class Misc
|
||||
{
|
||||
public $tabTitle = 'Misc Settings';
|
||||
public $miscSettings;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function updateMiscSettings(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'icon' => 'nullable|max:10000|mimes:jpg,png,jpeg',
|
||||
'favicon' => 'nullable|max:10000|mimes:ico',
|
||||
]);
|
||||
|
||||
if ($request->hasFile('icon')) {
|
||||
$request->file('icon')->storeAs('public', 'icon.png');
|
||||
}
|
||||
|
||||
if ($request->hasFile('favicon')) {
|
||||
$request->file('favicon')->storeAs('public', 'favicon.ico');
|
||||
}
|
||||
|
||||
$values = [
|
||||
//SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form)
|
||||
"SETTINGS::MISC:PHPMYADMIN:URL" => "phpmyadmin-url"
|
||||
];
|
||||
|
||||
|
||||
foreach ($values as $key => $value) {
|
||||
$param = $request->get($value);
|
||||
if (!$param) {
|
||||
$param = "";
|
||||
}
|
||||
Settings::where('key', $key)->update(['value' => $param]);
|
||||
Cache::forget("setting" . ':' . $key);
|
||||
Session::remove("locale");
|
||||
}
|
||||
|
||||
|
||||
return redirect()->route('admin.settings.index')->with('success', 'Misc settings updated!');
|
||||
}
|
||||
|
||||
}
|
|
@ -6,6 +6,7 @@ use App\Classes\Pterodactyl;
|
|||
use App\Classes\PterodactylWrapper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Server;
|
||||
use App\Models\Settings;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
|
@ -161,7 +162,7 @@ class ServerController extends Controller
|
|||
return $server->suspended ? $server->suspended->diffForHumans() : '';
|
||||
})
|
||||
->editColumn('name', function (Server $server) {
|
||||
return '<a class="text-info" target="_blank" href="' . env('PTERODACTYL_URL', 'http://localhost') . '/admin/servers/view/' . $server->pterodactyl_id . '">' . $server->name . '</a>';
|
||||
return '<a class="text-info" target="_blank" href="' . Settings::getValueByKey("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/admin/servers/view/' . $server->pterodactyl_id . '">' . $server->name . '</a>';
|
||||
})
|
||||
->rawColumns(['user', 'actions', 'status', 'name'])
|
||||
->make();
|
||||
|
|
|
@ -41,25 +41,6 @@ class SettingsController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
public function updateIcons(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'icon' => 'nullable|max:10000|mimes:jpg,png,jpeg',
|
||||
'favicon' => 'nullable|max:10000|mimes:ico',
|
||||
]);
|
||||
|
||||
if ($request->hasFile('icon')) {
|
||||
$request->file('icon')->storeAs('public', 'icon.png');
|
||||
}
|
||||
|
||||
if ($request->hasFile('favicon')) {
|
||||
$request->file('favicon')->storeAs('public', 'favicon.ico');
|
||||
}
|
||||
|
||||
return redirect()->route('admin.settings.index')->with('success', __('Icons updated!'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function updatevalue(Request $request)
|
||||
{
|
||||
|
@ -91,8 +72,7 @@ class SettingsController extends Controller
|
|||
$query = Settings::
|
||||
where('key', 'like', '%SYSTEM%')
|
||||
->orWhere('key', 'like', '%USER%')
|
||||
->orWhere('key', 'like', '%SERVER%')
|
||||
->orWhere('key', 'like', '%PAYMENTS%');
|
||||
->orWhere('key', 'like', '%SERVER%');
|
||||
|
||||
return datatables($query)
|
||||
->addColumn('actions', function (Settings $setting) {
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
|
|||
use App\Classes\Pterodactyl;
|
||||
use App\Events\UserUpdateCreditsEvent;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Settings;
|
||||
use App\Models\User;
|
||||
use App\Notifications\DynamicNotification;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
|
@ -300,7 +301,7 @@ class UserController extends Controller
|
|||
return '<span class="badge ' . $badgeColor . '">' . $user->role . '</span>';
|
||||
})
|
||||
->editColumn('name', function (User $user) {
|
||||
return '<a class="text-info" target="_blank" href="' . env('PTERODACTYL_URL', 'http://localhost') . '/admin/users/view/' . $user->pterodactyl_id . '">' . $user->name . '</a>';
|
||||
return '<a class="text-info" target="_blank" href="' . Settings::getValueByKey("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/admin/users/view/' . $user->pterodactyl_id . '">' . $user->name . '</a>';
|
||||
})
|
||||
->orderColumn('last_seen', function ($query, $order) {
|
||||
$query->orderBy('last_seen', $order);
|
||||
|
|
|
@ -1,11 +1,25 @@
|
|||
<div class="tab-pane mt-3" id="dashboard">
|
||||
<div class="tab-pane mt-3" id="misc">
|
||||
<form method="POST" enctype="multipart/form-data" class="mb-3"
|
||||
action="{{ route('admin.settings.update.icons') }}">
|
||||
action="{{ route('admin.settings.update.miscsettings') }}">
|
||||
@csrf
|
||||
@method('PATCH')
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-lg-4 col-12">
|
||||
|
||||
<!-- PHPMYADMIN -->
|
||||
|
||||
<!-- Icetoast das sieht auch kacke aus... -->
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control mb-3">
|
||||
<label for="phpmyadmin-url">{{ __('The URL to your PHPMYADMIN Panel. Must not end with a /, leave blank to remove database button') }}</label>
|
||||
<input x-model="phpmyadmin-url" id="phpmyadmin-url" name="phpmyadmin-url" type="text"
|
||||
value="{{ App\Models\Settings::getValueByKey("SETTINGS::MISC:PHPMYADMIN:URL") }}"
|
||||
class="form-control @error('phpmyadmin-url') is-invalid @enderror">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-file mb-3 mt-3">
|
||||
<input type="file" accept="image/png,image/jpeg,image/jpg" class="custom-file-input" name="icon"
|
|
@ -149,7 +149,7 @@
|
|||
</div>
|
||||
|
||||
<div class="card-footer d-flex align-items-center justify-content-between">
|
||||
<a href="{{ env('PTERODACTYL_URL', 'http://localhost') }}/server/{{ $server->identifier }}"
|
||||
<a href="{{ \App\Models\Settings::getValueByKey("SETTINGS::SYSTEM:PTERODACTYL:URL") }}/server/{{ $server->identifier }}"
|
||||
target="__blank"
|
||||
class="btn btn-info mx-3 w-100 align-items-center justify-content-center d-flex">
|
||||
<i class="fas fa-tools mr-2"></i>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Classes\Settings\Misc;
|
||||
use App\Classes\Settings\Payments;
|
||||
use App\Http\Controllers\Admin\ActivityLogController;
|
||||
use App\Http\Controllers\Admin\ApplicationApiController;
|
||||
|
@ -133,10 +134,10 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () {
|
|||
Route::patch('settings/updatevalue', [SettingsController::class, 'updatevalue'])->name('settings.updatevalue');
|
||||
|
||||
#settings
|
||||
Route::patch('settings/update/icons', [SettingsController::class, 'updateIcons'])->name('settings.update.icons');
|
||||
Route::patch('settings/update/invoice-settings', [Invoices::class, 'updateInvoiceSettings'])->name('settings.update.invoicesettings');
|
||||
Route::patch('settings/update/language', [Language::class, 'updateLanguageSettings'])->name('settings.update.languagesettings');
|
||||
Route::patch('settings/update/payment', [Payments::class, 'updatePaymentSettings'])->name('settings.update.paymentsettings');
|
||||
Route::patch('settings/update/misc', [Misc::class, 'updateMiscSettings'])->name('settings.update.miscsettings');
|
||||
Route::resource('settings', SettingsController::class)->only('index');
|
||||
|
||||
#invoices
|
||||
|
|
Loading…
Reference in a new issue