This commit is contained in:
Ludovic CANDELLIER
2021-11-07 19:58:38 +01:00
parent f3b6504723
commit dd396a86aa
22 changed files with 143 additions and 48 deletions

View File

@@ -15,7 +15,7 @@ class ArticlesDataTable extends DataTable
public function query(Article $model)
{
$model = $model::with(['article_nature', 'image'])->withCount(['categories', 'tags', 'offers']);
$model = $model::with(['article_nature', 'image'])->withCount(['categories', 'images', 'offers', 'tags']);
$model = self::filterByArticleNature($model);
return $this->buildQuery($model);
}
@@ -35,7 +35,14 @@ class ArticlesDataTable extends DataTable
->editColumn('article_nature.name', function (Article $article) {
return $article->article_nature ? $article->article_nature->name : '';
})
->rawColumns(['thumb', 'action']);
->editColumn('tags2', function (Article $article) {
$html = '';
foreach ($article->tags as $tag) {
$html .= '<span class="btn btn-xs btn-secondary pb-2">' . $tag->slug . '</span> ';
}
return $html;
})
->rawColumns(['tags2', 'thumb', 'action']);
return parent::modifier($datatables);
}
@@ -45,9 +52,11 @@ class ArticlesDataTable extends DataTable
Column::make('article_nature.name')->title('Nature'),
Column::make('thumb')->title('')->searchable(false)->orderable(false)->width(40)->class('text-center'),
Column::make('name')->title('Nom'),
Column::make('tags_count')->title('Tags')->class('text-right')->searchable(false),
Column::make('categories_count')->title('Rayons')->class('text-right')->searchable(false),
Column::make('offers_count')->title('Offres')->class('text-right')->searchable(false),
Column::make('tags2')->title('Tags')->searchable(false)->orderable(false),
Column::make('tags_count')->title('#Tag')->class('text-right')->searchable(false),
Column::make('categories_count')->title('#Ray')->class('text-right')->searchable(false),
Column::make('offers_count')->title('#Ofr')->class('text-right')->searchable(false),
Column::make('images_count')->title('#Pho')->class('text-right')->searchable(false),
$this->makeColumnButtons(),
];
}