NavSideBarComponent.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace App\View\Components;
  3. use App\Helpers\Utils;
  4. use App\Models\Parameter\Modal;
  5. use Illuminate\View\Component;
  6. use Exception;
  7. class NavSideBarComponent extends Component
  8. {
  9. public $menuCode;
  10. /**
  11. * Create a new component instance.
  12. *
  13. * @return void
  14. */
  15. public function __construct($menuCode = '')
  16. {
  17. $this->menuCode = $menuCode;
  18. }
  19. /**
  20. * Get the view / contents that represent the component.
  21. *
  22. * @return \Illuminate\Contracts\View\View|\Closure|string
  23. */
  24. public function render()
  25. {
  26. // dd(session('GateToken'));
  27. $sortType = session()->get('user.SortMenu.C2');
  28. try {
  29. if (empty(session('user'))) {
  30. $menu = Utils::getMainMenu($sortType);
  31. } else if (session('user') && isset(session('user')['UserId'])) {
  32. $menu = Utils::getMainMenu($sortType);
  33. } else {
  34. $menu = [ 'Page' => [] ];
  35. }
  36. } catch (Exception $e) {
  37. $menu = [ 'Page' => [] ];
  38. }
  39. if (empty($menu['Page'])) {
  40. notify()->info('사용권한은 시스템 관리자에게 문의하시기 바랍니다.', 'Info', 'bottomRight');
  41. }
  42. $menuPages = [];
  43. if (isset($menu['Page']) && is_array($menu['Page'])) $menuPages = $menu['Page'];
  44. $menuPages = Utils::bpaEncoding($menuPages)->toArray();
  45. $menuList = Utils::formatMenuList($menuPages);
  46. $bpa = request('bpa');
  47. $disableLMenu = [];
  48. $enableRMenu = [];
  49. if (isset($bpa)) {
  50. $disableLMenu = Utils::bpaDecoding($bpa)['disable_l_menu'];
  51. $enableRMenu = Utils::bpaDecoding($bpa)['enable_r_menu'];
  52. }
  53. $form = (new Modal('/etc/common/user-menu'))->getData();
  54. // dd($menuList);
  55. // dd($menuPages);
  56. return view('components.nav-side-bar-component', compact('form','menuList', 'menuPages', 'disableLMenu', 'enableRMenu'));
  57. }
  58. }