Add the count field to Item model.
This commit is contained in:
@@ -19,8 +19,21 @@ class Item extends Model
|
||||
'price',
|
||||
'image',
|
||||
'category_id',
|
||||
// if an item in a cart, then the count is a nonzero value.
|
||||
'count',
|
||||
];
|
||||
|
||||
public function getCount()
|
||||
{
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
public function setCount($count = 1)
|
||||
{
|
||||
$this->count = $count;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
|
||||
Reference in New Issue
Block a user