Add lowest price first draft.

This commit is contained in:
2025-05-13 23:34:51 +02:00
parent 2471a61076
commit beb717f9b9
4 changed files with 11 additions and 5 deletions

View File

@@ -41,6 +41,11 @@ class Product extends Model
return $this->hasOne(Price::class)->latestOfMany('created_at');
}
public function lowestPrice(): HasOne
{
return $this->hasOne(Price::class)->ofMany('price', 'MIN');
}
public function stock(): HasMany
{
return $this->hasMany(Stock::class);