SettingsController.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 tabs as laravel view paths
  19. $tabs = [];
  20. foreach (glob(Theme::getViewPaths()[0] . '/admin/settings/tabs/*.blade.php') as $filename) {
  21. $tabs[] = 'admin.settings.tabs.'.basename($filename, '.blade.php');
  22. }
  23. //Generate a html list item for each tab based on tabs file basename, set first tab as active
  24. $tabListItems = [];
  25. foreach ($tabs as $tab) {
  26. $tabName = str_replace('admin.settings.tabs.', '', $tab);
  27. $tabListItems[] = '<li class="nav-item">
  28. <a class="nav-link '.(empty($tabListItems) ? 'active' : '').'" data-toggle="pill" href="#'.$tabName.'">
  29. '.__(ucfirst($tabName)).'
  30. </a></li>';
  31. }
  32. $themes = array_diff(scandir(base_path('themes')), array('..', '.'));
  33. return view('admin.settings.index', [
  34. 'tabs' => $tabs,
  35. 'tabListItems' => $tabListItems,
  36. 'themes' => $themes,
  37. 'active_theme' => Theme::active(),
  38. ]);
  39. }
  40. }