47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\DataTables\Shop;
|
|
|
|
use Yajra\DataTables\Html\Column;
|
|
use App\DataTables\ParentDataTable as DataTable;
|
|
use App\Models\Shop\Article;
|
|
|
|
class ArticlesDataTable extends DataTable
|
|
{
|
|
public $model_name = 'Articles';
|
|
|
|
public function query(Article $model)
|
|
{
|
|
// $model = $model::with('Family')->select('shop_articles.*','family.name as family_name')->join('shop_article_families as family', 'family.id', '=', 'shop_articles.article_family_id')->groupBy('shop_articles.id');
|
|
$model = $model::with('Family')->select('shop_articles.*');
|
|
// $model = $model::joinRelations('Family')->select('shop_articles.*','shop_article_families.name as family_name');
|
|
return self::buildQuery($model);
|
|
}
|
|
|
|
protected function getColumns()
|
|
{
|
|
/*
|
|
$columns = [];
|
|
$columns[] = [
|
|
'name' => 'family',
|
|
'data' => 'family.name',
|
|
'title' => 'Famille',
|
|
'orderable' => false
|
|
];
|
|
$columns[] = [
|
|
'name' => 'name',
|
|
'title' => 'Nom',
|
|
];
|
|
$columns[] = self::makeColumnButtons();
|
|
return $columns;
|
|
*/
|
|
return [
|
|
Column::make('family.name')->title('Famille')->orderable(false),
|
|
Column::make('name')->title('Nom'),
|
|
self::makeColumnButtons(),
|
|
];
|
|
|
|
}
|
|
|
|
}
|