Add new filters to display on website
This commit is contained in:
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user