Increase speed of processing the prices and products. Because this is getting out of hand.
This commit was merged in pull request #33.
This commit is contained in:
@@ -20,6 +20,10 @@ use function Symfony\Component\Clock\now;
|
||||
* @property string $modelCode
|
||||
* @property string $url
|
||||
* @property int $starred
|
||||
* @property float $priceCurrent
|
||||
* @property float $priceLowest
|
||||
* @property float $productStandardPrice
|
||||
* @property float $lowestProductPrice30Days
|
||||
*/
|
||||
class Product extends Model
|
||||
{
|
||||
@@ -45,6 +49,10 @@ class Product extends Model
|
||||
{
|
||||
return $this->hasOne(Price::class)->ofMany('price', 'MIN');
|
||||
}
|
||||
public function newestPrice(): HasOne
|
||||
{
|
||||
return $this->hasOne(Price::class)->latest();
|
||||
}
|
||||
|
||||
public function stock(): HasMany
|
||||
{
|
||||
@@ -53,9 +61,7 @@ class Product extends Model
|
||||
|
||||
public function currentStock(): HasOne
|
||||
{
|
||||
return $this->stock()->one()->ofMany()->withDefault(function (Stock $stock) {
|
||||
$stock->stock = 0;
|
||||
});
|
||||
return $this->stock()->one()->ofMany()->withDefault(fn (Stock $stock) => $stock->stock = 0);
|
||||
}
|
||||
|
||||
public function toggleStarred(): self
|
||||
|
||||
Reference in New Issue
Block a user