Add a badge for stock

This commit is contained in:
Krzysztof Płaczek committed 2024-11-23 11:34:00 +01:00
1 parent 0db4bacff4
commit a6b108cb74
5 files changed
+35 -14

No files matched your search

+7
View File
@@ -44,6 +44,13 @@ class Product extends Model
return $this->hasMany(Stock::class);
}
public function currentStock(): HasOne
{
return $this->stock()->one()->ofMany()->withDefault(function (Stock $stock) {
$stock->stock = 0;
});
}
public function toggleStarred(): self
{
$this->starred = !$this->starred;