// +---------------------------------------------------------------------- declare (strict_types=1); namespace app\store\middleware; use cores\Request; use app\common\service\store\User as StoreUserService; /** * 中间件:当前商城ID */ class Store { /** * 前置中间件 * @param Request $request * @param \Closure $next * @return mixed */ public function handle(Request $request, \Closure $next) { if ($storeId = StoreUserService::getLoginStoreId()) { $request->setStoreId($storeId); } return $next($request); } }