Synchro back-office, fix on tariffs

This commit is contained in:
Ludovic CANDELLIER
2021-10-26 21:41:46 +02:00
parent c150be2c3e
commit 86f6ee9a13
45 changed files with 1095 additions and 406 deletions

View File

@@ -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);
}
}