LeftSidebarComponent.php 2.3 KB

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