12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace App\Http\Middleware\Shop;
- use App\Helpers\Utils;
- use App\Services\CallApiService;
- use Closure;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Route;
- class HeaderData
- {
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
- * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
- */
- public function handle(Request $request, Closure $next)
- {
- $mainMenuPerm = Utils::getProMainMenu();
- $mainMenuPermPage = collect($mainMenuPerm['Page'])->filter(function ($menu) {
- return $menu['Sort'] === 'primary';
- })->toArray();
- $topMenuPermPage = collect($mainMenuPerm['Page'])->filter(function ($menu) {
- return $menu['Sort'] === 'top';
- })->toArray();
- $mainMenuList = Utils::formatMenuList($mainMenuPermPage, 'MenuCode');
- $topMenuList = Utils::formatMenuList($topMenuPermPage, 'MenuCode');
- $headerPart = app(CallApiService::class)->callApi([
- 'url' => 'list-type1-book',
- 'data' => [
- 'Book' => [
- [
- 'QueryVars' => [
- 'QueryName' => 'pro:shop/wish',
- 'SubSimpleFilter' => "image_type = 'thumb'",
- 'IsntPagination' => true,
- ],
- 'PageVars' => [
- 'Limit' => 100000
- ]
- ],
- [
- 'QueryVars' => [
- 'QueryName' => 'point2u::pro:shop/cart',
- 'SubSimpleFilter' => "image_type = 'thumb'",
- 'IsntPagination' => true,
- ],
- 'PageVars' => [
- 'Limit' => 100000
- ]
- ]
- ]
- ],
- ]);
- $currentRoute = Route::currentRouteName();
- view()->share('mainMenuList', $mainMenuList);
- view()->share('topMenuList', $topMenuList);
- view()->share('headerPart', $headerPart);
- view()->share('currentRoute', $topMenuPermPage);
- return $next($request);
- }
- }
|