[WIP] Add thumb on offers, refactor categories, try to fix counter on relations polymorphic with eage loader, bad pattern !

This commit is contained in:
Ludovic CANDELLIER
2021-12-17 00:30:07 +01:00
parent 2be07ce72c
commit a3c6fc6ebe
26 changed files with 171 additions and 107 deletions

View File

@@ -12,20 +12,24 @@ class CategoriesDataTable extends DataTable
public function query(Category $model)
{
$model = $model::with(['tags.articles'])->withCount(['articles', 'tags']);
$model = $model::with(['tags.articles'])->withCount(['articles','tags']);
return $this->buildQuery($model);
}
public function modifier($datatables)
{
$datatables
->editColumn('name', function (Category $category) {
return $category->name;
})
->editColumn('visible', function (Category $category) {
return view("components.form.toggle", [
'name' => 'visible',
'value' => $category->visible,
'on' => __('visible'),
'off' => __('invisible'),
'meta' => 'data-id=' . $category->id,
'size' => 'sm',
'size' => 'xs',
]);
})
->editColumn('articles_tagged_count', function (Category $category) {
@@ -45,9 +49,9 @@ class CategoriesDataTable extends DataTable
return [
Column::make('visible')->title('visible')->width(60)->title(''),
Column::make('name')->title('Nom'),
Column::make('articles_count')->title('#Art')->class('text-right')->searchable(false)->width(60),
Column::make('articles_count')->title('#Art')->class('text-right')->orderable(false)->searchable(false)->width(60),
Column::make('tags_count')->title('#Tags')->class('text-right')->searchable(false)->width(60),
Column::make('articles_tagged_count')->title('#ArtTag')->class('text-right')->searchable(false)->width(60),
Column::make('articles_tagged_count')->title('#ArtTag')->class('text-right')->searchable(false)->orderable(false)->width(60),
$this->makeColumnButtons(),
];
}