64 lines
2 KiB
PHP
64 lines
2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Contracts\Foundation\Application;
|
|
use Illuminate\Contracts\View\Factory;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Http\Response;
|
|
use Qirolab\Theme\Theme;
|
|
|
|
class SettingsController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return Application|Factory|View|Response
|
|
*/
|
|
public function index()
|
|
{
|
|
|
|
// get all other settings in app/Settings directory
|
|
// group items by file name like $categories
|
|
$settings = collect();
|
|
foreach (scandir(app_path('Settings')) as $file) {
|
|
if (in_array($file, ['.', '..'])) {
|
|
continue;
|
|
}
|
|
$className = 'App\\Settings\\' . str_replace('.php', '', $file);
|
|
$options = (new $className())->toArray();
|
|
|
|
if (method_exists($className, 'getOptionInputData')) {
|
|
$optionInputData = $className::getOptionInputData();
|
|
} else {
|
|
$optionInputData = [];
|
|
}
|
|
|
|
$optionsData = [];
|
|
|
|
foreach ($options as $key => $value) {
|
|
$optionsData[$key] = [
|
|
'value' => $value,
|
|
'label' => $optionInputData[$key]['label'] ?? ucwords(str_replace('_', ' ', $key)),
|
|
'type' => $optionInputData[$key]['type'] ?? 'string',
|
|
'description' => $optionInputData[$key]['description'] ?? '',
|
|
'options' => $optionInputData[$key]['options'] ?? [],
|
|
];
|
|
}
|
|
|
|
$settings[str_replace('Settings.php', '', $file)] = $optionsData;
|
|
}
|
|
|
|
$settings->sort();
|
|
|
|
|
|
$themes = array_diff(scandir(base_path('themes')), array('..', '.'));
|
|
|
|
return view('admin.settings.index', [
|
|
'settings' => $settings->all(),
|
|
'themes' => $themes,
|
|
'active_theme' => Theme::active(),
|
|
]);
|
|
}
|
|
}
|