Code format
This commit is contained in:
parent
e1e3ee9568
commit
5c4ae14dbc
|
|
@ -21,7 +21,7 @@ class ProductController extends Controller
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$requestData = $request->all();
|
$requestData = $request->all();
|
||||||
if (!isset($requestData['sort'])) {
|
if (! isset($requestData['sort'])) {
|
||||||
$requestData['sort'] = 'products.updated_at';
|
$requestData['sort'] = 'products.updated_at';
|
||||||
}
|
}
|
||||||
$productList = ProductRepo::list($requestData);
|
$productList = ProductRepo::list($requestData);
|
||||||
|
|
@ -149,15 +149,15 @@ class ProductController extends Controller
|
||||||
array_unshift($taxClasses, ['title' => trans('admin/builder.text_no'), 'id' => 0]);
|
array_unshift($taxClasses, ['title' => trans('admin/builder.text_no'), 'id' => 0]);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'product' => $product,
|
'product' => $product,
|
||||||
'descriptions' => $descriptions ?? [],
|
'descriptions' => $descriptions ?? [],
|
||||||
'category_ids' => $categoryIds ?? [],
|
'category_ids' => $categoryIds ?? [],
|
||||||
'product_attributes' => ProductAttributeResource::collection($product->attributes),
|
'product_attributes' => ProductAttributeResource::collection($product->attributes),
|
||||||
'relations' => ProductResource::collection($product->relations)->resource,
|
'relations' => ProductResource::collection($product->relations)->resource,
|
||||||
'languages' => LanguageRepo::all(),
|
'languages' => LanguageRepo::all(),
|
||||||
'tax_classes' => $taxClasses,
|
'tax_classes' => $taxClasses,
|
||||||
'weight_classes' => Weight::getWeightUnits(),
|
'weight_classes' => Weight::getWeightUnits(),
|
||||||
'source' => [
|
'source' => [
|
||||||
'categories' => CategoryRepo::flatten(locale()),
|
'categories' => CategoryRepo::flatten(locale()),
|
||||||
],
|
],
|
||||||
'_redirect' => $this->getRedirect(),
|
'_redirect' => $this->getRedirect(),
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class SettingController extends Controller
|
||||||
$data = [
|
$data = [
|
||||||
'countries' => CountryRepo::listEnabled(),
|
'countries' => CountryRepo::listEnabled(),
|
||||||
'currencies' => CurrencyRepo::listEnabled(),
|
'currencies' => CurrencyRepo::listEnabled(),
|
||||||
'multi_filter' => $multiFilter,
|
'multi_filter' => $multiFilter,
|
||||||
'tax_address' => $taxAddress,
|
'tax_address' => $taxAddress,
|
||||||
'customer_groups' => CustomerGroupDetail::collection(CustomerGroupRepo::list())->jsonSerialize(),
|
'customer_groups' => CustomerGroupDetail::collection(CustomerGroupRepo::list())->jsonSerialize(),
|
||||||
'themes' => $themes,
|
'themes' => $themes,
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class ProductService
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
$data['brand_id'] = (int) $data['brand_id'];
|
$data['brand_id'] = (int) $data['brand_id'];
|
||||||
$data['weight'] = (float) $data['weight'];
|
$data['weight'] = (float) $data['weight'];
|
||||||
$data['variables'] = json_decode($data['variables']);
|
$data['variables'] = json_decode($data['variables']);
|
||||||
$product->fill($data);
|
$product->fill($data);
|
||||||
$product->updated_at = now();
|
$product->updated_at = now();
|
||||||
|
|
|
||||||
|
|
@ -19,25 +19,27 @@ class Weight
|
||||||
'oz' => 0.035,
|
'oz' => 0.035,
|
||||||
'lb' => 0.0022046,
|
'lb' => 0.0022046,
|
||||||
];
|
];
|
||||||
|
|
||||||
public const DEFAULT_CLASS = 'g';
|
public const DEFAULT_CLASS = 'g';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getWeightUnits() : array
|
public static function getWeightUnits(): array
|
||||||
{
|
{
|
||||||
return array_keys(self::WEIGHT_CLASS);
|
return array_keys(self::WEIGHT_CLASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function convert($weight, $from, $to = '')
|
public static function convert($weight, $from, $to = '')
|
||||||
{
|
{
|
||||||
if (!$to) {
|
if (! $to) {
|
||||||
$to = self::DEFAULT_CLASS;
|
$to = self::DEFAULT_CLASS;
|
||||||
}
|
}
|
||||||
if (empty($weight)) {
|
if (empty($weight)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $weight * self::WEIGHT_CLASS[$to] / self::WEIGHT_CLASS[$from];
|
return $weight * self::WEIGHT_CLASS[$to] / self::WEIGHT_CLASS[$from];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ class OrderRepo
|
||||||
|
|
||||||
$shippingAddress = Address::query()->findOrFail($shippingAddressId);
|
$shippingAddress = Address::query()->findOrFail($shippingAddressId);
|
||||||
$paymentAddress = Address::query()->findOrFail($paymentAddressId);
|
$paymentAddress = Address::query()->findOrFail($paymentAddressId);
|
||||||
$email = $customer->email;
|
$email = $customer->email;
|
||||||
} else {
|
} else {
|
||||||
$shippingAddress = new Address($current['guest_shipping_address'] ?? []);
|
$shippingAddress = new Address($current['guest_shipping_address'] ?? []);
|
||||||
$paymentAddress = new Address($current['guest_payment_address'] ?? []);
|
$paymentAddress = new Address($current['guest_payment_address'] ?? []);
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ class ProductRepo
|
||||||
|
|
||||||
public static function getFilterAttribute($data): array
|
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'])
|
->select(['pa.attribute_id', 'pa.attribute_value_id'])
|
||||||
->with(['attributes.attribute.description', 'attributes.attribute_value.description'])
|
->with(['attributes.attribute.description', 'attributes.attribute_value.description'])
|
||||||
->leftJoin('product_attributes as pa', 'pa.product_id', 'products.id')
|
->leftJoin('product_attributes as pa', 'pa.product_id', 'products.id')
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ class ImageService
|
||||||
public function __construct($image)
|
public function __construct($image)
|
||||||
{
|
{
|
||||||
$this->placeholderImage = system_setting('base.placeholder');
|
$this->placeholderImage = system_setting('base.placeholder');
|
||||||
$this->image = $image ?: $this->placeholderImage;
|
$this->image = $image ?: $this->placeholderImage;
|
||||||
$this->imagePath = public_path($this->image);
|
$this->imagePath = public_path($this->image);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@
|
||||||
|
|
||||||
namespace Beike\Shop\Http\Controllers;
|
namespace Beike\Shop\Http\Controllers;
|
||||||
|
|
||||||
|
use Beike\Repositories\OrderRepo;
|
||||||
use Beike\Shop\Services\CheckoutService;
|
use Beike\Shop\Services\CheckoutService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Beike\Repositories\OrderRepo;
|
|
||||||
|
|
||||||
class CheckoutController extends Controller
|
class CheckoutController extends Controller
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,7 @@ class CheckoutService
|
||||||
foreach ($shipments as $shipment) {
|
foreach ($shipments as $shipment) {
|
||||||
$shipmentCodes = array_merge($shipmentCodes, array_column($shipment['quotes'], 'code'));
|
$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->updateShippingMethod($shipmentCodes[0] ?? '');
|
||||||
$this->totalService->setShippingMethod($shipmentCodes[0] ?? '');
|
$this->totalService->setShippingMethod($shipmentCodes[0] ?? '');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class Bootstrap
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
},1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ return [
|
||||||
'category' => 'Category',
|
'category' => 'Category',
|
||||||
'model' => 'Model',
|
'model' => 'Model',
|
||||||
'quantity' => 'Quantity',
|
'quantity' => 'Quantity',
|
||||||
'kg' => 'Kilogram',
|
'kg' => 'Kilogram',
|
||||||
'g' => 'Gram',
|
'g' => 'Gram',
|
||||||
'oz' => 'Ounce',
|
'oz' => 'Ounce',
|
||||||
'lb' => 'Pound',
|
'lb' => 'Pound',
|
||||||
|
|
||||||
'active' => 'Active',
|
'active' => 'Active',
|
||||||
'inactive' => 'Inactive',
|
'inactive' => 'Inactive',
|
||||||
|
|
|
||||||
|
|
@ -10,25 +10,25 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'index' => 'Checkout',
|
'index' => 'Checkout',
|
||||||
'address' => 'Address',
|
'address' => 'Address',
|
||||||
'payment_address' => 'Payment Address',
|
'payment_address' => 'Payment Address',
|
||||||
'same_as_shipping_address' => 'Same As Shipping Address',
|
'same_as_shipping_address' => 'Same As Shipping Address',
|
||||||
'chosen' => 'Chosen',
|
'chosen' => 'Chosen',
|
||||||
'edit' => 'Edit',
|
'edit' => 'Edit',
|
||||||
'choose_another_address' => 'Choose Another Address',
|
'choose_another_address' => 'Choose Another Address',
|
||||||
'add_new_address' => 'Add New Address',
|
'add_new_address' => 'Add New Address',
|
||||||
'payment_method' => 'Payment Method',
|
'payment_method' => 'Payment Method',
|
||||||
'delivery_method' => 'Delivery Method',
|
'delivery_method' => 'Delivery Method',
|
||||||
'cart_totals' => 'Cart Totals',
|
'cart_totals' => 'Cart Totals',
|
||||||
'submit_order' => 'Submit Order',
|
'submit_order' => 'Submit Order',
|
||||||
'enter_name' => 'Please type in your name',
|
'enter_name' => 'Please type in your name',
|
||||||
'enter_phone' => 'Please type your phone number',
|
'enter_phone' => 'Please type your phone number',
|
||||||
'enter_address' => 'Please enter detailed address 1',
|
'enter_address' => 'Please enter detailed address 1',
|
||||||
'select_province' => 'Please select province',
|
'select_province' => 'Please select province',
|
||||||
'enter_city' => 'Please fill in the city ',
|
'enter_city' => 'Please fill in the city ',
|
||||||
'check_form' => 'Please check that the form is filled out correctly',
|
'check_form' => 'Please check that the form is filled out correctly',
|
||||||
'error_payment_address' => 'Please select a billing address',
|
'error_payment_address' => 'Please select a billing address',
|
||||||
'checkout_success_title' => 'Thank you for your order!',
|
'checkout_success_title' => 'Thank you for your order!',
|
||||||
|
|
||||||
'payment' => [
|
'payment' => [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue