Fix bug on select2 in modal filters, add filters by tags and shelves on articles

This commit is contained in:
Ludovic CANDELLIER
2022-01-30 15:04:08 +01:00
parent 5799eb36fc
commit 5e5f12ddb2
6 changed files with 64 additions and 15 deletions

View File

@@ -17,6 +17,8 @@ class ArticlesDataTable extends DataTable
{
$model = $model::with(['article_nature', 'image'])->withCount(['categories', 'images', 'offers', 'tags']);
$model = self::filterByArticleNature($model);
$model = self::filterByCategory($model);
$model = self::filterByTag($model);
return $this->buildQuery($model);
}
@@ -26,6 +28,18 @@ class ArticlesDataTable extends DataTable
return $article_nature_id ? $model->byArticleNature($article_nature_id) : $model;
}
public static function filterByCategory($model, $category_id = false)
{
$category_id = $category_id ? $category_id : self::isFilteredByField('category_id');
return $category_id ? $model->byCategory($category_id) : $model;
}
public static function filterByTag($model, $tag_id = false)
{
$tag_id = $tag_id ? $tag_id : self::isFilteredByField('tag_id');
return $tag_id ? $model->byTag($tag_id) : $model;
}
public function modifier($datatables)
{
$datatables