SettingsController.php 1.3 KB

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