diff --git a/packages/Webkul/Admin/src/Http/Controllers/Sales/ShipmentController.php b/packages/Webkul/Admin/src/Http/Controllers/Sales/ShipmentController.php index 8af17fb4c..8bdf6bba4 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Sales/ShipmentController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Sales/ShipmentController.php @@ -88,13 +88,15 @@ class ShipmentController extends Controller 'shipment.items.*.*' => 'required|numeric|min:0', ]); - if (! $this->isInventoryValidate(request()->all())) { + $data = request()->all(); + + if (! $this->isInventoryValidate($data)) { session()->flash('error', trans('admin::app.sales.shipments.quantity-invalid')); return redirect()->back(); } - $this->shipmentRepository->create(array_merge(request()->all(), [ + $this->shipmentRepository->create(array_merge($data, [ 'order_id' => $orderId, ])); diff --git a/packages/Webkul/Attribute/src/Models/Attribute.php b/packages/Webkul/Attribute/src/Models/Attribute.php index 3379a8f8a..0759109fb 100755 --- a/packages/Webkul/Attribute/src/Models/Attribute.php +++ b/packages/Webkul/Attribute/src/Models/Attribute.php @@ -56,8 +56,8 @@ class Attribute extends TranslatableModel implements AttributeContract public function scopeFilterableAttributes(Builder $query): Builder { return $query->where('is_filterable', 1) - ->where('swatch_type', '<>', 'image') - ->orderBy('position'); + ->where('swatch_type', '<>', 'image') + ->orderBy('position'); } /** diff --git a/packages/Webkul/Attribute/src/Models/AttributeFamily.php b/packages/Webkul/Attribute/src/Models/AttributeFamily.php index 236683353..833ef9b68 100755 --- a/packages/Webkul/Attribute/src/Models/AttributeFamily.php +++ b/packages/Webkul/Attribute/src/Models/AttributeFamily.php @@ -27,10 +27,10 @@ class AttributeFamily extends Model implements AttributeFamilyContract public function custom_attributes() { return (AttributeProxy::modelClass())::join('attribute_group_mappings', 'attributes.id', '=', 'attribute_group_mappings.attribute_id') - ->join('attribute_groups', 'attribute_group_mappings.attribute_group_id', '=', 'attribute_groups.id') - ->join('attribute_families', 'attribute_groups.attribute_family_id', '=', 'attribute_families.id') - ->where('attribute_families.id', $this->id) - ->select('attributes.*'); + ->join('attribute_groups', 'attribute_group_mappings.attribute_group_id', '=', 'attribute_groups.id') + ->join('attribute_families', 'attribute_groups.attribute_family_id', '=', 'attribute_families.id') + ->where('attribute_families.id', $this->id) + ->select('attributes.*'); } diff --git a/packages/Webkul/Attribute/src/Models/AttributeGroup.php b/packages/Webkul/Attribute/src/Models/AttributeGroup.php index 5ec2b8d3c..091f7077a 100755 --- a/packages/Webkul/Attribute/src/Models/AttributeGroup.php +++ b/packages/Webkul/Attribute/src/Models/AttributeGroup.php @@ -17,7 +17,7 @@ class AttributeGroup extends Model implements AttributeGroupContract public function custom_attributes() { return $this->belongsToMany(AttributeProxy::modelClass(), 'attribute_group_mappings') - ->withPivot('position') - ->orderBy('pivot_position', 'asc'); + ->withPivot('position') + ->orderBy('pivot_position', 'asc'); } } \ No newline at end of file diff --git a/packages/Webkul/CartRule/src/Models/CartRule.php b/packages/Webkul/CartRule/src/Models/CartRule.php index 3addf91ce..ac796ab9a 100644 --- a/packages/Webkul/CartRule/src/Models/CartRule.php +++ b/packages/Webkul/CartRule/src/Models/CartRule.php @@ -111,7 +111,7 @@ class CartRule extends Model implements CartRuleContract public function coupon_code(): \Illuminate\Database\Eloquent\Relations\HasOne { return $this->cart_rule_coupon() - ->where('is_primary', 1); + ->where('is_primary', 1); } /** @@ -121,8 +121,7 @@ class CartRule extends Model implements CartRuleContract */ public function getCouponCodeAttribute() { - $coupon = $this->coupon_code() - ->first(); + $coupon = $this->coupon_code()->first(); if (! $coupon) { return; diff --git a/packages/Webkul/Category/src/Models/Category.php b/packages/Webkul/Category/src/Models/Category.php index 1c9aa0abb..422030fbd 100755 --- a/packages/Webkul/Category/src/Models/Category.php +++ b/packages/Webkul/Category/src/Models/Category.php @@ -135,13 +135,11 @@ class Category extends TranslatableModel implements CategoryContract 'parent_id', '=', null, - ], - [ + ], [ '_lft', '<=', $this->_lft, - ], - [ + ], [ '_rgt', '>=', $this->_rgt, @@ -163,6 +161,7 @@ class Category extends TranslatableModel implements CategoryContract while (isset($category->parent)) { $category = $category->parent; + $categories[] = $category; } diff --git a/packages/Webkul/Checkout/src/Models/Cart.php b/packages/Webkul/Checkout/src/Models/Cart.php index ec27a6a7e..2cd9c057d 100755 --- a/packages/Webkul/Checkout/src/Models/Cart.php +++ b/packages/Webkul/Checkout/src/Models/Cart.php @@ -20,18 +20,13 @@ class Cart extends Model implements CartContract 'updated_at', ]; - // protected $with = [ - // 'items', - // 'items.children', - // ]; - /** * To get relevant associated items with the cart instance */ public function items(): \Illuminate\Database\Eloquent\Relations\HasMany { return $this->hasMany(CartItemProxy::modelClass()) - ->whereNull('parent_id'); + ->whereNull('parent_id'); } /** @@ -56,7 +51,7 @@ class Cart extends Model implements CartContract public function billing_address(): \Illuminate\Database\Eloquent\Relations\HasMany { return $this->addresses() - ->where('address_type', CartAddress::ADDRESS_TYPE_BILLING); + ->where('address_type', CartAddress::ADDRESS_TYPE_BILLING); } /** @@ -64,8 +59,7 @@ class Cart extends Model implements CartContract */ public function getBillingAddressAttribute() { - return $this->billing_address() - ->first(); + return $this->billing_address()->first(); } /** @@ -74,7 +68,7 @@ class Cart extends Model implements CartContract public function shipping_address(): \Illuminate\Database\Eloquent\Relations\HasMany { return $this->addresses() - ->where('address_type', CartAddress::ADDRESS_TYPE_SHIPPING); + ->where('address_type', CartAddress::ADDRESS_TYPE_SHIPPING); } /** @@ -82,8 +76,7 @@ class Cart extends Model implements CartContract */ public function getShippingAddressAttribute() { - return $this->shipping_address() - ->first(); + return $this->shipping_address()->first(); } /** @@ -100,7 +93,7 @@ class Cart extends Model implements CartContract public function selected_shipping_rate(): \Illuminate\Database\Eloquent\Relations\HasManyThrough { return $this->shipping_rates() - ->where('method', $this->shipping_method); + ->where('method', $this->shipping_method); } /** @@ -109,8 +102,8 @@ class Cart extends Model implements CartContract public function getSelectedShippingRateAttribute() { return $this->selected_shipping_rate() - ->where('method', $this->shipping_method) - ->first(); + ->where('method', $this->shipping_method) + ->first(); } /** @@ -162,7 +155,7 @@ class Cart extends Model implements CartContract public function hasProductsWithQuantityBox(): bool { foreach ($this->items as $item) { - if ($item->product->getTypeInstance()->showQuantityBox() === true) { + if ($item->product->getTypeInstance()->showQuantityBox()) { return true; } } diff --git a/packages/Webkul/Checkout/src/Models/CartItem.php b/packages/Webkul/Checkout/src/Models/CartItem.php index 3c190fdd3..716cc5b5b 100755 --- a/packages/Webkul/Checkout/src/Models/CartItem.php +++ b/packages/Webkul/Checkout/src/Models/CartItem.php @@ -41,9 +41,9 @@ class CartItem extends Model implements CartItemContract public function product_flat() { return (ProductFlatProxy::modelClass())::where('product_flat.product_id', $this->product_id) - ->where('product_flat.locale', app()->getLocale()) - ->where('product_flat.channel', core()->getCurrentChannelCode()) - ->select('product_flat.*'); + ->where('product_flat.locale', app()->getLocale()) + ->where('product_flat.channel', core()->getCurrentChannelCode()) + ->select('product_flat.*'); } /** @@ -51,8 +51,7 @@ class CartItem extends Model implements CartItemContract */ public function getProductFlatAttribute() { - return $this->product_flat() - ->first(); + return $this->product_flat()->first(); } public function cart(): HasOne diff --git a/packages/Webkul/Customer/src/Models/Customer.php b/packages/Webkul/Customer/src/Models/Customer.php index 74520eb77..a04894fbe 100755 --- a/packages/Webkul/Customer/src/Models/Customer.php +++ b/packages/Webkul/Customer/src/Models/Customer.php @@ -202,9 +202,7 @@ class Customer extends Authenticatable implements CustomerContract, JWTSubject */ public function isWishlistShared(): bool { - return $this->wishlist_items()->where('shared', 1)->first() - ? true - : false; + return (bool) $this->wishlist_items()->where('shared', 1)->first(); } /** diff --git a/packages/Webkul/Product/src/Models/Product.php b/packages/Webkul/Product/src/Models/Product.php index 98b61c31f..d216ed9a6 100755 --- a/packages/Webkul/Product/src/Models/Product.php +++ b/packages/Webkul/Product/src/Models/Product.php @@ -491,8 +491,10 @@ class Product extends Model implements ProductContract $locale = core()->checkRequestedLocaleCodeInRequestedChannel(); $channel = core()->getRequestedChannelCode(); - if (array_key_exists($this->id, self::$loadedAttributeValues) - && array_key_exists($attribute->id, self::$loadedAttributeValues[$this->id])) { + if ( + array_key_exists($this->id, self::$loadedAttributeValues) + && array_key_exists($attribute->id, self::$loadedAttributeValues[$this->id]) + ) { return self::$loadedAttributeValues[$this->id][$attribute->id]; } diff --git a/packages/Webkul/Product/src/Models/ProductAttributeValue.php b/packages/Webkul/Product/src/Models/ProductAttributeValue.php index 54a056604..252fce7c9 100755 --- a/packages/Webkul/Product/src/Models/ProductAttributeValue.php +++ b/packages/Webkul/Product/src/Models/ProductAttributeValue.php @@ -27,17 +27,17 @@ class ProductAttributeValue extends Model implements ProductAttributeValueContra * @var array */ public static $attributeTypeFields = [ - 'text' => 'text_value', - 'textarea' => 'text_value', - 'price' => 'float_value', - 'boolean' => 'boolean_value', - 'select' => 'integer_value', + 'text' => 'text_value', + 'textarea' => 'text_value', + 'price' => 'float_value', + 'boolean' => 'boolean_value', + 'select' => 'integer_value', 'multiselect' => 'text_value', - 'datetime' => 'datetime_value', - 'date' => 'date_value', - 'file' => 'text_value', - 'image' => 'text_value', - 'checkbox' => 'text_value', + 'datetime' => 'datetime_value', + 'date' => 'date_value', + 'file' => 'text_value', + 'image' => 'text_value', + 'checkbox' => 'text_value', ]; /** diff --git a/packages/Webkul/Product/src/Models/ProductFlat.php b/packages/Webkul/Product/src/Models/ProductFlat.php index d58e00371..e08a0df8d 100644 --- a/packages/Webkul/Product/src/Models/ProductFlat.php +++ b/packages/Webkul/Product/src/Models/ProductFlat.php @@ -40,13 +40,6 @@ class ProductFlat extends Model implements ProductFlatContract 'attribute_family_id', ]; - /** - * Indicates if the model should be timestamped. - * - * @var boolean - */ - // public $timestamps = false; - /** * Get the index name for the model. * diff --git a/packages/Webkul/Sales/src/Models/Invoice.php b/packages/Webkul/Sales/src/Models/Invoice.php index 23edd0764..4048900a5 100755 --- a/packages/Webkul/Sales/src/Models/Invoice.php +++ b/packages/Webkul/Sales/src/Models/Invoice.php @@ -34,8 +34,8 @@ class Invoice extends Model implements InvoiceContract * @var array */ protected $statusLabel = [ - 'pending' => 'Pending', - 'paid' => 'Paid', + 'pending' => 'Pending', + 'paid' => 'Paid', 'refunded' => 'Refunded', ]; @@ -61,7 +61,7 @@ class Invoice extends Model implements InvoiceContract public function items(): HasMany { return $this->hasMany(InvoiceItemProxy::modelClass()) - ->whereNull('parent_id'); + ->whereNull('parent_id'); } /** @@ -86,7 +86,7 @@ class Invoice extends Model implements InvoiceContract public function address(): BelongsTo { return $this->belongsTo(OrderAddressProxy::modelClass(), 'order_address_id') - ->where('address_type', OrderAddress::ADDRESS_TYPE_BILLING); + ->where('address_type', OrderAddress::ADDRESS_TYPE_BILLING); } /** diff --git a/packages/Webkul/Sales/src/Models/Order.php b/packages/Webkul/Sales/src/Models/Order.php index d089ae84d..6786acf8b 100755 --- a/packages/Webkul/Sales/src/Models/Order.php +++ b/packages/Webkul/Sales/src/Models/Order.php @@ -234,8 +234,7 @@ class Order extends Model implements OrderContract public function haveStockableItems(): bool { foreach ($this->items as $item) { - if ($item->getTypeInstance() - ->isStockable()) { + if ($item->getTypeInstance()->isStockable()) { return true; } } @@ -378,8 +377,7 @@ class Order extends Model implements OrderContract } } - if ($this->base_grand_total_invoiced - $this->base_grand_total_refunded - $this->refunds() - ->sum('base_adjustment_fee') > 0) { + if ($this->base_grand_total_invoiced - $this->base_grand_total_refunded - $this->refunds()->sum('base_adjustment_fee') > 0) { return true; } diff --git a/packages/Webkul/Sales/src/Models/OrderAddress.php b/packages/Webkul/Sales/src/Models/OrderAddress.php index cfd98f53c..e3c27ac4b 100755 --- a/packages/Webkul/Sales/src/Models/OrderAddress.php +++ b/packages/Webkul/Sales/src/Models/OrderAddress.php @@ -53,9 +53,12 @@ class OrderAddress extends Address implements OrderAddressContract switch ($address->address_type) { case CartAddress::ADDRESS_TYPE_BILLING: $address->address_type = self::ADDRESS_TYPE_BILLING; + break; + case CartAddress::ADDRESS_TYPE_SHIPPING: $address->address_type = self::ADDRESS_TYPE_SHIPPING; + break; } }); diff --git a/packages/Webkul/Sales/src/Models/OrderItem.php b/packages/Webkul/Sales/src/Models/OrderItem.php index 2ad988915..f0f97df70 100755 --- a/packages/Webkul/Sales/src/Models/OrderItem.php +++ b/packages/Webkul/Sales/src/Models/OrderItem.php @@ -56,8 +56,7 @@ class OrderItem extends Model implements OrderItemContract */ public function isStockable(): bool { - return $this->getTypeInstance() - ->isStockable(); + return $this->getTypeInstance()->isStockable(); } /** diff --git a/packages/Webkul/Sales/src/Models/Refund.php b/packages/Webkul/Sales/src/Models/Refund.php index 6c70c9edd..d8f1f0855 100644 --- a/packages/Webkul/Sales/src/Models/Refund.php +++ b/packages/Webkul/Sales/src/Models/Refund.php @@ -45,7 +45,7 @@ class Refund extends Model implements RefundContract public function items(): HasMany { return $this->hasMany(RefundItemProxy::modelClass()) - ->whereNull('parent_id'); + ->whereNull('parent_id'); } /** diff --git a/packages/Webkul/Sales/src/Models/Shipment.php b/packages/Webkul/Sales/src/Models/Shipment.php index a20842960..dab917617 100755 --- a/packages/Webkul/Sales/src/Models/Shipment.php +++ b/packages/Webkul/Sales/src/Models/Shipment.php @@ -60,7 +60,7 @@ class Shipment extends Model implements ShipmentContract public function address(): BelongsTo { return $this->belongsTo(OrderAddressProxy::modelClass(), 'order_address_id') - ->where('address_type', OrderAddress::ADDRESS_TYPE_SHIPPING); + ->where('address_type', OrderAddress::ADDRESS_TYPE_SHIPPING); } /** diff --git a/packages/Webkul/Sitemap/src/Models/Category.php b/packages/Webkul/Sitemap/src/Models/Category.php index 19a4bcf44..8f6ebb3a2 100644 --- a/packages/Webkul/Sitemap/src/Models/Category.php +++ b/packages/Webkul/Sitemap/src/Models/Category.php @@ -13,7 +13,8 @@ class Category extends BaseCategory implements Sitemapable */ public function toSitemapTag(): Url | string | array { - if (! $this->slug + if ( + ! $this->slug || ! $this->status ) { return []; diff --git a/packages/Webkul/Sitemap/src/Models/Product.php b/packages/Webkul/Sitemap/src/Models/Product.php index 941ad77c4..2b92d7c3d 100644 --- a/packages/Webkul/Sitemap/src/Models/Product.php +++ b/packages/Webkul/Sitemap/src/Models/Product.php @@ -13,7 +13,8 @@ class Product extends BaseProduct implements Sitemapable */ public function toSitemapTag(): Url | string | array { - if (! $this->url_key + if ( + ! $this->url_key || ! $this->status || ! $this->visible_individually ) { diff --git a/packages/Webkul/Tax/src/Models/TaxCategory.php b/packages/Webkul/Tax/src/Models/TaxCategory.php index 97d262c79..c9baa06b8 100755 --- a/packages/Webkul/Tax/src/Models/TaxCategory.php +++ b/packages/Webkul/Tax/src/Models/TaxCategory.php @@ -31,7 +31,7 @@ class TaxCategory extends Model implements TaxCategoryContract public function tax_rates(): BelongsToMany { return $this->belongsToMany(TaxRateProxy::modelClass(), 'tax_categories_tax_rates', 'tax_category_id') - ->withPivot('id'); + ->withPivot('id'); } /** diff --git a/packages/Webkul/Velocity/src/Models/Content.php b/packages/Webkul/Velocity/src/Models/Content.php index 886e8937a..c174d481d 100644 --- a/packages/Webkul/Velocity/src/Models/Content.php +++ b/packages/Webkul/Velocity/src/Models/Content.php @@ -7,7 +7,6 @@ use Webkul\Velocity\Contracts\Content as ContentContract; class Content extends TranslatableModel implements ContentContract { - protected $table = 'velocity_contents'; public $translatedAttributes = [ diff --git a/packages/Webkul/Velocity/src/Models/VelocityMetadata.php b/packages/Webkul/Velocity/src/Models/VelocityMetadata.php index ebbcaa2fe..fb0f633d7 100644 --- a/packages/Webkul/Velocity/src/Models/VelocityMetadata.php +++ b/packages/Webkul/Velocity/src/Models/VelocityMetadata.php @@ -9,6 +9,4 @@ class VelocityMetadata extends Model implements VelocityMetadataContract { protected $table = 'velocity_meta_data'; - protected $guarded = []; - } \ No newline at end of file