D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
forge
/
ghanempharmacy.com
/
app
/
Models
/
Filename :
Cart.php
back
Copy
<?php namespace App\Models; use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasOne; /** * Class CartItem * * @property int $id Primary * @property int $customer_id * @property string $cart_group_id * @property int $product_id * @property string $product_type * @property string $digital_product_type * @property string $color * @property array $choices * @property array $variations * @property array $variant * @property int $quantity * @property float $price * @property float $tax * @property integer $is_checked * @property float $discount * @property string $tax_model * @property string $slug * @property string $name * @property string $thumbnail * @property int $seller_id * @property string $seller_is * @property Carbon $created_at * @property Carbon $updated_at * @property string $shop_info * @property float $shipping_cost * @property string $shipping_type * @property int $is_guest * * @package App\Models */ class Cart extends Model { protected $casts = [ 'id' => 'integer', 'customer_id' => 'integer', 'product_id' => 'integer', // 'choices' => 'array', // 'variations' => 'array', // 'variant' => 'array', 'quantity' => 'integer', 'price' => 'float', 'tax' => 'float', 'is_checked' => 'integer', 'discount' => 'float', 'seller_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'shipping_cost' => 'float', 'is_guest' => 'integer', ]; protected $fillable = [ 'customer_id', 'cart_group_id', 'product_id', 'product_type', 'digital_product_type', 'color', 'choices', 'variations', 'variant', 'quantity', 'price', 'tax', 'discount', 'tax_model', 'is_checked', 'slug', 'name', 'thumbnail', 'seller_id', 'seller_is', 'shop_info', 'shipping_cost', 'shipping_type', 'is_guest', 'bundle_id', 'bundle_name', 'has_bundle_gift', 'bundle_gift_products', 'gift_id', 'gift_deal_id', 'original_price', ]; public function cartShipping(): HasOne { return $this->hasOne(CartShipping::class, 'cart_group_id', 'cart_group_id'); } public function product(): BelongsTo { return $this->belongsTo(Product::class)->where('status', 1); } public function seller(): BelongsTo { return $this->belongsTo(Seller::class, 'seller_id'); } public function shop(): BelongsTo { return $this->belongsTo(Shop::class, 'seller_id', 'seller_id'); } public function allProducts(): BelongsTo { return $this->belongsTo(Product::class, 'product_id'); } protected static function boot(): void { parent::boot(); static::saved(function ($model) { cacheRemoveByType(type: 'carts'); }); static::deleted(function ($model) { cacheRemoveByType(type: 'carts'); }); } }