Create CartModel.php

This commit is contained in:
Patrick
2022-02-08 23:05:38 +01:00
committed by GitHub
parent c26b3b280a
commit 309d62fea4

48
src/Models/CartModel.php Normal file
View File

@@ -0,0 +1,48 @@
<?php
namespace Gloudemans\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Config;
class CartModel extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Config::get('cart.database.tables.cart_item');
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'row_id',
'cart_id',
'price',
'discount_rate',
'discount_fixed',
'taxRate',
'options'
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'options' => 'array', // Stored as JSON string, cast to array
];
/**
* Get the CartItems for the cart.
*/
public function items()
{
return $this->hasMany(CartItem::class);
}
}