Synchro back-office, fix on tariffs
This commit is contained in:
@@ -4,7 +4,8 @@ namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use BeyondCode\Comments\Traits\HasComments;
|
||||
use App\Traits\HasComments;
|
||||
|
||||
class Offer extends Model
|
||||
{
|
||||
use HasComments;
|
||||
@@ -17,6 +18,11 @@ class Offer extends Model
|
||||
return $this->belongsTo(Article::class);
|
||||
}
|
||||
|
||||
public function categories()
|
||||
{
|
||||
return $this->article->categories();
|
||||
}
|
||||
|
||||
public function variation()
|
||||
{
|
||||
return $this->belongsTo(Variation::class);
|
||||
@@ -26,4 +32,26 @@ class Offer extends Model
|
||||
{
|
||||
return $this->belongsTo(Tariff::class);
|
||||
}
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where('article_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByCategory($query, $category_id)
|
||||
{
|
||||
return $query->whereHas('article.categories', function ($query) use ($category_id) {
|
||||
$query->where('category_id', $category_id);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeByStatus($query, $id)
|
||||
{
|
||||
return $query->where('status_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByVariation($query, $id)
|
||||
{
|
||||
return $query->where('variation_id', $id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user