HeaderData.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace App\Http\Middleware\Shop;
  3. use App\Helpers\Utils;
  4. use App\Services\CallApiService;
  5. use Closure;
  6. use Illuminate\Http\Request;
  7. use Illuminate\Support\Facades\Route;
  8. class HeaderData
  9. {
  10. /**
  11. * Handle an incoming request.
  12. *
  13. * @param \Illuminate\Http\Request $request
  14. * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
  15. * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
  16. */
  17. public function handle(Request $request, Closure $next)
  18. {
  19. $mainMenuPerm = Utils::getProMainMenu();
  20. $mainMenuPermPage = collect($mainMenuPerm['Page'])->filter(function ($menu) {
  21. return $menu['Sort'] === 'primary';
  22. })->toArray();
  23. $topMenuPermPage = collect($mainMenuPerm['Page'])->filter(function ($menu) {
  24. return $menu['Sort'] === 'top';
  25. })->toArray();
  26. $mainMenuList = Utils::formatMenuList($mainMenuPermPage, 'MenuCode');
  27. $topMenuList = Utils::formatMenuList($topMenuPermPage, 'MenuCode');
  28. dd($topMenuList);
  29. $headerPart = app(CallApiService::class)->callApi([
  30. 'url' => 'list-type1-book',
  31. 'data' => [
  32. 'Book' => [
  33. [
  34. 'QueryVars' => [
  35. 'QueryName' => 'pro:shop/wish',
  36. 'SubSimpleFilter' => "image_type = 'thumb'",
  37. 'IsntPagination' => true,
  38. ],
  39. 'PageVars' => [
  40. 'Limit' => 100000
  41. ]
  42. ],
  43. [
  44. 'QueryVars' => [
  45. 'QueryName' => 'point2u::pro:shop/cart',
  46. 'SubSimpleFilter' => "image_type = 'thumb'",
  47. 'IsntPagination' => true,
  48. ],
  49. 'PageVars' => [
  50. 'Limit' => 100000
  51. ]
  52. ]
  53. ]
  54. ],
  55. ]);
  56. $currentRoute = Route::currentRouteName();
  57. view()->share('mainMenuList', $mainMenuList);
  58. view()->share('topMenuList', $topMenuList);
  59. view()->share('headerPart', $headerPart);
  60. view()->share('currentRoute', $topMenuPermPage);
  61. return $next($request);
  62. }
  63. }