Add new filters to display on website

This commit is contained in:
Ludovic CANDELLIER
2020-08-20 01:10:38 +02:00
parent 79ffd9a022
commit c66fe78f66
3 changed files with 32 additions and 1 deletions

View File

@@ -43,7 +43,7 @@ class Article extends Model implements HasMedia
public function product() public function product()
{ {
return $this->belongsTo($this->model, 'model_id'); return $this->morphTo();
} }
public function scopeByArticle($query, $id) public function scopeByArticle($query, $id)
@@ -51,4 +51,15 @@ class Article extends Model implements HasMedia
return $query->where('shop_articles.id',$id); return $query->where('shop_articles.id',$id);
} }
public function scopeByCategory($query, $category_id)
{
}
public function scopeByFamily($query, $id)
{
return $query->where('shop_articles.article_family_id',$id);
}
} }

View File

@@ -33,4 +33,11 @@ class ArticleAttribute extends Model
{ {
return $query->where('attribute_value_id', $id); return $query->where('attribute_value_id', $id);
} }
public function scopeByFamily($query, $id)
{
return $query->whereHas('attribute_value', function ($query) use ($id) {
$query->byFamily($id);
});
}
} }

View File

@@ -33,7 +33,20 @@ class ArticlePrice extends Model
return $query->whereHas('article', function ($query) use ($id) { return $query->whereHas('article', function ($query) use ($id) {
$query->byArticle($id); $query->byArticle($id);
}); });
}
public function scopeByAttributeValue($query, $id)
{
return $query->whereHas('article_attribute', function ($query) use ($id) {
$query->byAttributeValue($id);
});
}
public function scopeByFamily($query, $id)
{
return $query->whereHas('article_attribute', function ($query) use ($id) {
$query->byFamily($id);
});
} }
} }