refactoring of admin datatables
This commit is contained in:
41
app/Datatables/Admin/Shop/ArticleNaturesDataTable.php
Normal file
41
app/Datatables/Admin/Shop/ArticleNaturesDataTable.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\ArticleNature;
|
||||
use App\Repositories\Shop\ArticleNatures;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class ArticleNaturesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'article_natures';
|
||||
|
||||
public function query(ArticleNature $model)
|
||||
{
|
||||
$model = $model::withCount('Articles');
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('product_type', function (ArticleNature $nature) {
|
||||
return ArticleNatures::getProductTypeName($nature->product_type);
|
||||
})
|
||||
->rawColumns(['action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('product_type')->title('Famille de produit')->width(140),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('articles_count')->title('Nb Art.')->addClass('text-right')->searchable(false)->width(60),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user