RightSideBarComponent.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\View\Components;
  3. use App\Helpers\Utils;
  4. use Illuminate\View\Component;
  5. use App\Models\Parameter\Modal;
  6. use Exception;
  7. class RightSideBarComponent extends Component
  8. {
  9. /**
  10. * Create a new component instance.
  11. *
  12. * @return void
  13. */
  14. public function __construct()
  15. {
  16. //
  17. }
  18. /**
  19. * Get the view / contents that represent the component.
  20. *
  21. * @return \Illuminate\Contracts\View\View|\Closure|string
  22. */
  23. public function render()
  24. {
  25. $sortType = session()->get('user.SortMenu.C2');
  26. $form = (new Modal('/etc/common/user-menu'))->getData();
  27. $currentBpa = Utils::bpaDecoding(request('bpa'));
  28. try {
  29. $menuPage = Utils::getMainMenu($sortType)['Page'] ?? [];
  30. } catch (Exception $e) {
  31. $menuPage = [];
  32. }
  33. $bpa = Utils::bpaEncoding($menuPage)->pluck('bpa')->toArray();
  34. $menuPage = collect($menuPage)->map(function ($menu, $index) use ($bpa) {
  35. return array_merge($menu, ['bpa' => $bpa[$index]]);
  36. });
  37. return view('components.right-side-bar-component', compact('form', 'currentBpa', 'menuPage'));
  38. }
  39. }