Code format

This commit is contained in:
Edward Yang 2023-04-07 16:53:18 +08:00
parent e1e3ee9568
commit 5c4ae14dbc
12 changed files with 45 additions and 43 deletions

View File

@ -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(),

View File

@ -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,

View File

@ -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();

View File

@ -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];
}
}

View File

@ -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'] ?? []);

View File

@ -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')

View File

@ -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);
}
/**

View File

@ -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
{

View File

@ -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] ?? '');
}

View File

@ -24,7 +24,7 @@ class Bootstrap
}
return $output;
},1);
}, 1);
}
/**

View File

@ -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',

View File

@ -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' => [