diff --git a/beike/Shop/Http/Controllers/Account/LoginController.php b/beike/Shop/Http/Controllers/Account/LoginController.php index 86552e40..2d4d5642 100644 --- a/beike/Shop/Http/Controllers/Account/LoginController.php +++ b/beike/Shop/Http/Controllers/Account/LoginController.php @@ -35,20 +35,30 @@ class LoginController extends Controller public function store(LoginRequest $request) { - $guestCartProduct = CartRepo::allCartProducts(0); - if (! auth(Customer::AUTH_GUARD)->attempt($request->only('email', 'password'))) { - throw new NotAcceptableHttpException(trans('shop/login.email_or_password_error')); + $data = [ + 'request_data' => $request->all(), + ]; + + try { + hook_action('shop.account.login.before', $data); + + $guestCartProduct = CartRepo::allCartProducts(0); + if (! auth(Customer::AUTH_GUARD)->attempt($request->only('email', 'password'))) { + throw new NotAcceptableHttpException(trans('shop/login.email_or_password_error')); + } + + $customer = current_customer(); + if ($customer && $customer->status != 1) { + Auth::guard(Customer::AUTH_GUARD)->logout(); + + throw new NotFoundHttpException(trans('shop/login.customer_inactive')); + } + + CartRepo::mergeGuestCart($customer, $guestCartProduct); + + return json_success(trans('shop/login.login_successfully')); + } catch (\Exception $e) { + return json_fail($e->getMessage()); } - - $customer = current_customer(); - if ($customer && $customer->status != 1) { - Auth::guard(Customer::AUTH_GUARD)->logout(); - - throw new NotFoundHttpException(trans('shop/login.customer_inactive')); - } - - CartRepo::mergeGuestCart($customer, $guestCartProduct); - - return json_success(trans('shop/login.login_successfully')); } } diff --git a/beike/Shop/Http/Resources/CartDetail.php b/beike/Shop/Http/Resources/CartDetail.php index e8645b68..0da5450a 100644 --- a/beike/Shop/Http/Resources/CartDetail.php +++ b/beike/Shop/Http/Resources/CartDetail.php @@ -26,7 +26,7 @@ class CartDetail extends JsonResource $subTotal = $price * $this->quantity; $image = $sku->image ?: $product->image; - return [ + $result = [ 'cart_id' => $this->id, 'product_id' => $this->product_id, 'sku_id' => $this->product_sku_id, @@ -44,5 +44,7 @@ class CartDetail extends JsonResource 'subtotal_format' => currency_format($subTotal), 'variant_labels' => trim($sku->getVariantLabel()), ]; + + return hook_filter('resource.cart.detail', $result); } } diff --git a/beike/Shop/Http/Resources/SkuDetail.php b/beike/Shop/Http/Resources/SkuDetail.php index 6f315747..db8b2683 100644 --- a/beike/Shop/Http/Resources/SkuDetail.php +++ b/beike/Shop/Http/Resources/SkuDetail.php @@ -17,7 +17,7 @@ class SkuDetail extends JsonResource { public function toArray($request): array { - return [ + $result = [ 'id' => $this->id, 'variants' => $this->variants ?: [], 'position' => $this->position, @@ -37,5 +37,7 @@ class SkuDetail extends JsonResource 'quantity' => $this->quantity, 'is_default' => $this->is_default, ]; + + return hook_filter('resource.sku.detail', $result); } } diff --git a/resources/beike/admin/views/pages/products/form/form.blade.php b/resources/beike/admin/views/pages/products/form/form.blade.php index a5336d79..d72fcf89 100644 --- a/resources/beike/admin/views/pages/products/form/form.blade.php +++ b/resources/beike/admin/views/pages/products/form/form.blade.php @@ -107,9 +107,11 @@