Add indexes to the database.

This commit was merged in pull request #60.
This commit is contained in:
2026-02-05 08:40:34 +01:00
parent a545bfe2ab
commit 67019e3933
3 changed files with 57 additions and 9 deletions

View File

@@ -63,7 +63,7 @@ class Product extends Model
public function newestPrice(): HasOne
{
return $this->hasOne(Price::class)->latest();
return $this->hasOne(Price::class)->latest()->take(1);
}
public function stock(): HasMany
@@ -73,7 +73,7 @@ class Product extends Model
public function currentStock(): HasOne
{
return $this->stock()->one()->ofMany()->withDefault(fn(Stock $stock) => $stock->stock = 0);
return $this->stock()->one()->ofMany()->withDefault(fn(Stock $stock) => $stock->stock = 0)->take(1);
}
public function toggleStarred(): self