SettingsController.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. class SettingsController extends Controller
  9. {
  10. /**
  11. * Display a listing of the resource.
  12. *
  13. * @return Application|Factory|View|Response
  14. */
  15. public function index()
  16. {
  17. //Get all tabs as laravel view paths
  18. $tabs = [];
  19. foreach (glob(resource_path('views/admin/settings/tabs/*.blade.php')) as $filename) {
  20. $tabs[] = 'admin.settings.tabs.'.basename($filename, '.blade.php');
  21. }
  22. //Generate a html list item for each tab based on tabs file basename, set first tab as active
  23. $tabListItems = [];
  24. foreach ($tabs as $tab) {
  25. $tabName = str_replace('admin.settings.tabs.', '', $tab);
  26. $tabListItems[] = '<li class="nav-item">
  27. <a class="nav-link '.(empty($tabListItems) ? 'active' : '').'" data-toggle="pill" href="#'.$tabName.'">
  28. '.__(ucfirst($tabName)).'
  29. </a></li>';
  30. }
  31. return view('admin.settings.index', [
  32. 'tabs' => $tabs,
  33. 'tabListItems' => $tabListItems,
  34. ]);
  35. }
  36. }