mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-25 02:10:39 +00:00
controller refactoring part 5
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ use Support\Demo\Actions\DemoService;
|
||||
use Cartalyst\Stripe\Exception\UnauthorizedException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class SettingController extends Controller
|
||||
class AdminSettingsController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private DemoService $demo
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace Domain\Settings\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Domain\Settings\Models\Setting;
|
||||
|
||||
class SettingsController
|
||||
{
|
||||
/**
|
||||
* List of allowed settings to get from public request
|
||||
*/
|
||||
private array $blacklist = [
|
||||
'purchase_code',
|
||||
'license',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get selected settings from public route
|
||||
*/
|
||||
public function __invoke(
|
||||
Request $request
|
||||
): Collection {
|
||||
if (str_contains($request->get('column'), '|')) {
|
||||
$columns = collect(explode('|', $request->get('column')))
|
||||
->each(function ($column) {
|
||||
if (in_array($column, $this->blacklist)) {
|
||||
abort(401);
|
||||
}
|
||||
});
|
||||
|
||||
return Setting::whereIn('name', $columns)
|
||||
->pluck('value', 'name');
|
||||
}
|
||||
|
||||
if (in_array($request->get('column'), $this->blacklist)) {
|
||||
abort(401);
|
||||
}
|
||||
|
||||
return Setting::where('name', $request->get('column'))
|
||||
->pluck('value', 'name');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user