eloquent($query)
->addColumn('action', function ($data) {
return view('product::categories.partials.actions', compact('data'));
});
}
public function query(Category $model) {
return $model->newQuery()->withCount('products');
}
public function html() {
return $this->builder()
->setTableId('product_categories-table')
->columns($this->getColumns())
->minifiedAjax()
->dom("<'row'<'col-md-3'l><'col-md-5 mb-2'B><'col-md-4'f>> .
'tr' .
<'row'<'col-md-5'i><'col-md-7 mt-2'p>>")
->orderBy(0, 'asc')
->buttons(
Button::make('excel')
->text(' Excel'),
Button::make('print')
->text(' Print'),
Button::make('reset')
->text(' Reset'),
Button::make('reload')
->text(' Reload')
);
}
protected function getColumns() {
return [
Column::make('category_code')
->addClass('text-center'),
Column::make('category_name')
->addClass('text-center'),
Column::make('products_count')
->addClass('text-center'),
Column::computed('action')
->exportable(false)
->printable(false)
->addClass('text-center'),
];
}
protected function filename() {
return 'ProductCategories_' . date('YmdHis');
}
}