Add the count field to Item model.

This commit is contained in:
2023-06-19 18:12:57 +03:00
parent 563254c725
commit ada0abd69d
2 changed files with 14 additions and 0 deletions
+13
View File
@@ -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);