SettingsController.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Contracts\Foundation\Application;
  5. use Illuminate\Contracts\View\Factory;
  6. use Illuminate\Contracts\View\View;
  7. use Illuminate\Http\Response;
  8. use Qirolab\Theme\Theme;
  9. class SettingsController extends Controller
  10. {
  11. /**
  12. * Display a listing of the resource.
  13. *
  14. * @return Application|Factory|View|Response
  15. */
  16. public function index()
  17. {
  18. // get all other settings in app/Settings directory
  19. // group items by file name like $categories
  20. $settings = collect();
  21. foreach (scandir(app_path('Settings')) as $file) {
  22. if (in_array($file, ['.', '..'])) {
  23. continue;
  24. }
  25. $className = 'App\\Settings\\' . str_replace('.php', '', $file);
  26. $settings[str_replace('Settings.php', '', $file)] = (new $className())->toCollection()->all();
  27. }
  28. $settings->sort();
  29. $themes = array_diff(scandir(base_path('themes')), array('..', '.'));
  30. return view('admin.settings.index', [
  31. 'settings' => $settings->all(),
  32. 'themes' => $themes,
  33. 'active_theme' => Theme::active(),
  34. ]);
  35. }
  36. }