[WIP] Add thumb on offers, refactor categories, try to fix counter on relations polymorphic with eage loader, bad pattern !
This commit is contained in:
@@ -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(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Datatables\Shop;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Offer;
|
||||
use App\Repositories\Shop\Offers;
|
||||
|
||||
class OffersDataTable extends DataTable
|
||||
{
|
||||
@@ -34,6 +35,9 @@ class OffersDataTable extends DataTable
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('thumb', function (Offer $offer) {
|
||||
return '<img src="' . Offers::getThumbSrc($offer) . '">';
|
||||
})
|
||||
->editColumn('status_id', function (Offer $offer) {
|
||||
return view("components.form.toggle", [
|
||||
'value' => $offer->status_id,
|
||||
@@ -46,7 +50,7 @@ class OffersDataTable extends DataTable
|
||||
->editColumn('stock_delayed', function (Offer $offer) {
|
||||
return $offer->stock_delayed . ' - ' . $offer->delay_type;
|
||||
})
|
||||
->rawColumns(['active', 'action']);
|
||||
->rawColumns(['active', 'thumb', 'action']);
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
@@ -55,6 +59,7 @@ class OffersDataTable extends DataTable
|
||||
return [
|
||||
Column::make('status_id')->title('')->width(40),
|
||||
Column::make('article.article_nature.name')->title('Nature'),
|
||||
Column::make('thumb')->title('')->width(40),
|
||||
Column::make('article.name')->title('Article'),
|
||||
Column::make('variation.name')->title('Déclinaison'),
|
||||
Column::make('tariff.name')->title('Tarif'),
|
||||
|
||||
Reference in New Issue
Block a user