From 5c4ae14dbce069ff84ae568733121f31b87501d6 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Fri, 7 Apr 2023 16:53:18 +0800 Subject: [PATCH] Code format --- .../Http/Controllers/ProductController.php | 18 ++++----- .../Http/Controllers/SettingController.php | 2 +- beike/Admin/Services/ProductService.php | 2 +- beike/Libraries/Weight.php | 6 ++- beike/Repositories/OrderRepo.php | 2 +- beike/Repositories/ProductRepo.php | 2 +- beike/Services/ImageService.php | 4 +- .../Http/Controllers/CheckoutController.php | 2 +- beike/Shop/Services/CheckoutService.php | 2 +- plugins/Social/Bootstrap.php | 2 +- resources/lang/en/product.php | 8 ++-- resources/lang/en/shop/checkout.php | 38 +++++++++---------- 12 files changed, 45 insertions(+), 43 deletions(-) diff --git a/beike/Admin/Http/Controllers/ProductController.php b/beike/Admin/Http/Controllers/ProductController.php index 47212a3d..1cd31d53 100644 --- a/beike/Admin/Http/Controllers/ProductController.php +++ b/beike/Admin/Http/Controllers/ProductController.php @@ -21,7 +21,7 @@ class ProductController extends Controller public function index(Request $request) { $requestData = $request->all(); - if (!isset($requestData['sort'])) { + if (! isset($requestData['sort'])) { $requestData['sort'] = 'products.updated_at'; } $productList = ProductRepo::list($requestData); @@ -149,15 +149,15 @@ class ProductController extends Controller array_unshift($taxClasses, ['title' => trans('admin/builder.text_no'), 'id' => 0]); $data = [ - 'product' => $product, - 'descriptions' => $descriptions ?? [], - 'category_ids' => $categoryIds ?? [], - 'product_attributes' => ProductAttributeResource::collection($product->attributes), - 'relations' => ProductResource::collection($product->relations)->resource, - 'languages' => LanguageRepo::all(), - 'tax_classes' => $taxClasses, + 'product' => $product, + 'descriptions' => $descriptions ?? [], + 'category_ids' => $categoryIds ?? [], + 'product_attributes' => ProductAttributeResource::collection($product->attributes), + 'relations' => ProductResource::collection($product->relations)->resource, + 'languages' => LanguageRepo::all(), + 'tax_classes' => $taxClasses, 'weight_classes' => Weight::getWeightUnits(), - 'source' => [ + 'source' => [ 'categories' => CategoryRepo::flatten(locale()), ], '_redirect' => $this->getRedirect(), diff --git a/beike/Admin/Http/Controllers/SettingController.php b/beike/Admin/Http/Controllers/SettingController.php index 04d16eae..a161c5e8 100644 --- a/beike/Admin/Http/Controllers/SettingController.php +++ b/beike/Admin/Http/Controllers/SettingController.php @@ -42,7 +42,7 @@ class SettingController extends Controller $data = [ 'countries' => CountryRepo::listEnabled(), 'currencies' => CurrencyRepo::listEnabled(), - 'multi_filter' => $multiFilter, + 'multi_filter' => $multiFilter, 'tax_address' => $taxAddress, 'customer_groups' => CustomerGroupDetail::collection(CustomerGroupRepo::list())->jsonSerialize(), 'themes' => $themes, diff --git a/beike/Admin/Services/ProductService.php b/beike/Admin/Services/ProductService.php index 912facdb..872ef17f 100644 --- a/beike/Admin/Services/ProductService.php +++ b/beike/Admin/Services/ProductService.php @@ -27,7 +27,7 @@ class ProductService DB::beginTransaction(); $data['brand_id'] = (int) $data['brand_id']; - $data['weight'] = (float) $data['weight']; + $data['weight'] = (float) $data['weight']; $data['variables'] = json_decode($data['variables']); $product->fill($data); $product->updated_at = now(); diff --git a/beike/Libraries/Weight.php b/beike/Libraries/Weight.php index decbffca..47d3ec30 100644 --- a/beike/Libraries/Weight.php +++ b/beike/Libraries/Weight.php @@ -19,25 +19,27 @@ class Weight 'oz' => 0.035, 'lb' => 0.0022046, ]; + public const DEFAULT_CLASS = 'g'; public function __construct() { } - public static function getWeightUnits() : array + public static function getWeightUnits(): array { return array_keys(self::WEIGHT_CLASS); } public static function convert($weight, $from, $to = '') { - if (!$to) { + if (! $to) { $to = self::DEFAULT_CLASS; } if (empty($weight)) { return 0; } + return $weight * self::WEIGHT_CLASS[$to] / self::WEIGHT_CLASS[$from]; } } diff --git a/beike/Repositories/OrderRepo.php b/beike/Repositories/OrderRepo.php index 51df9bb7..e23f9498 100644 --- a/beike/Repositories/OrderRepo.php +++ b/beike/Repositories/OrderRepo.php @@ -199,7 +199,7 @@ class OrderRepo $shippingAddress = Address::query()->findOrFail($shippingAddressId); $paymentAddress = Address::query()->findOrFail($paymentAddressId); - $email = $customer->email; + $email = $customer->email; } else { $shippingAddress = new Address($current['guest_shipping_address'] ?? []); $paymentAddress = new Address($current['guest_payment_address'] ?? []); diff --git a/beike/Repositories/ProductRepo.php b/beike/Repositories/ProductRepo.php index b42f18e2..5c3fe08a 100644 --- a/beike/Repositories/ProductRepo.php +++ b/beike/Repositories/ProductRepo.php @@ -199,7 +199,7 @@ class ProductRepo public static function getFilterAttribute($data): array { - $builder = self::getBuilder(array_diff_key($data, ['attr'=>'', 'price'=>''])) + $builder = self::getBuilder(array_diff_key($data, ['attr' => '', 'price' => ''])) ->select(['pa.attribute_id', 'pa.attribute_value_id']) ->with(['attributes.attribute.description', 'attributes.attribute_value.description']) ->leftJoin('product_attributes as pa', 'pa.product_id', 'products.id') diff --git a/beike/Services/ImageService.php b/beike/Services/ImageService.php index 0be0345c..167ed1e5 100644 --- a/beike/Services/ImageService.php +++ b/beike/Services/ImageService.php @@ -29,8 +29,8 @@ class ImageService public function __construct($image) { $this->placeholderImage = system_setting('base.placeholder'); - $this->image = $image ?: $this->placeholderImage; - $this->imagePath = public_path($this->image); + $this->image = $image ?: $this->placeholderImage; + $this->imagePath = public_path($this->image); } /** diff --git a/beike/Shop/Http/Controllers/CheckoutController.php b/beike/Shop/Http/Controllers/CheckoutController.php index 547beb58..419eb7b7 100644 --- a/beike/Shop/Http/Controllers/CheckoutController.php +++ b/beike/Shop/Http/Controllers/CheckoutController.php @@ -11,9 +11,9 @@ namespace Beike\Shop\Http\Controllers; +use Beike\Repositories\OrderRepo; use Beike\Shop\Services\CheckoutService; use Illuminate\Http\Request; -use Beike\Repositories\OrderRepo; class CheckoutController extends Controller { diff --git a/beike/Shop/Services/CheckoutService.php b/beike/Shop/Services/CheckoutService.php index 1b052416..6c0403b6 100644 --- a/beike/Shop/Services/CheckoutService.php +++ b/beike/Shop/Services/CheckoutService.php @@ -243,7 +243,7 @@ class CheckoutService foreach ($shipments as $shipment) { $shipmentCodes = array_merge($shipmentCodes, array_column($shipment['quotes'], 'code')); } - if (!in_array($currentCart->shipping_method_code, $shipmentCodes)) { + if (! in_array($currentCart->shipping_method_code, $shipmentCodes)) { $this->updateShippingMethod($shipmentCodes[0] ?? ''); $this->totalService->setShippingMethod($shipmentCodes[0] ?? ''); } diff --git a/plugins/Social/Bootstrap.php b/plugins/Social/Bootstrap.php index 88519330..fa572c7a 100644 --- a/plugins/Social/Bootstrap.php +++ b/plugins/Social/Bootstrap.php @@ -24,7 +24,7 @@ class Bootstrap } return $output; - },1); + }, 1); } /** diff --git a/resources/lang/en/product.php b/resources/lang/en/product.php index eb55b2e7..862f1cb1 100644 --- a/resources/lang/en/product.php +++ b/resources/lang/en/product.php @@ -19,10 +19,10 @@ return [ 'category' => 'Category', 'model' => 'Model', 'quantity' => 'Quantity', - 'kg' => 'Kilogram', - 'g' => 'Gram', - 'oz' => 'Ounce', - 'lb' => 'Pound', + 'kg' => 'Kilogram', + 'g' => 'Gram', + 'oz' => 'Ounce', + 'lb' => 'Pound', 'active' => 'Active', 'inactive' => 'Inactive', diff --git a/resources/lang/en/shop/checkout.php b/resources/lang/en/shop/checkout.php index 503671c2..36f367dd 100644 --- a/resources/lang/en/shop/checkout.php +++ b/resources/lang/en/shop/checkout.php @@ -10,25 +10,25 @@ */ return [ - 'index' => 'Checkout', - 'address' => 'Address', - 'payment_address' => 'Payment Address', - 'same_as_shipping_address' => 'Same As Shipping Address', - 'chosen' => 'Chosen', - 'edit' => 'Edit', - 'choose_another_address' => 'Choose Another Address', - 'add_new_address' => 'Add New Address', - 'payment_method' => 'Payment Method', - 'delivery_method' => 'Delivery Method', - 'cart_totals' => 'Cart Totals', - 'submit_order' => 'Submit Order', - 'enter_name' => 'Please type in your name', - 'enter_phone' => 'Please type your phone number', - 'enter_address' => 'Please enter detailed address 1', - 'select_province' => 'Please select province', - 'enter_city' => 'Please fill in the city ', - 'check_form' => 'Please check that the form is filled out correctly', - 'error_payment_address' => 'Please select a billing address', + 'index' => 'Checkout', + 'address' => 'Address', + 'payment_address' => 'Payment Address', + 'same_as_shipping_address' => 'Same As Shipping Address', + 'chosen' => 'Chosen', + 'edit' => 'Edit', + 'choose_another_address' => 'Choose Another Address', + 'add_new_address' => 'Add New Address', + 'payment_method' => 'Payment Method', + 'delivery_method' => 'Delivery Method', + 'cart_totals' => 'Cart Totals', + 'submit_order' => 'Submit Order', + 'enter_name' => 'Please type in your name', + 'enter_phone' => 'Please type your phone number', + 'enter_address' => 'Please enter detailed address 1', + 'select_province' => 'Please select province', + 'enter_city' => 'Please fill in the city ', + 'check_form' => 'Please check that the form is filled out correctly', + 'error_payment_address' => 'Please select a billing address', 'checkout_success_title' => 'Thank you for your order!', 'payment' => [