Promo endpoint that display only products on sale.
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Krzysiej\RyobiCrawler\Models;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
/**
|
||||
* @property integer $skuID
|
||||
@@ -28,6 +29,11 @@ class Product extends Model
|
||||
{
|
||||
return $this->hasMany(Price::class);
|
||||
}
|
||||
|
||||
public function currentPrice(): HasOne
|
||||
{
|
||||
return $this->hasOne(Price::class)->latestOfMany('created_at');
|
||||
}
|
||||
public function stock(): HasMany
|
||||
{
|
||||
return $this->hasMany(Stock::class);
|
||||
|
||||
Reference in New Issue
Block a user