Add relations in tables, add saving states for datatables, minor fixes

This commit is contained in:
Ludovic CANDELLIER
2021-09-14 23:14:03 +02:00
parent 1dcc3e34a9
commit ffb9f81353
16 changed files with 255 additions and 47 deletions

View File

@@ -14,9 +14,7 @@ class ArticlesDataTable extends DataTable
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('article_nature')->select('shop_articles.*');
$model = $model::with('article_nature')->joinRelationship('article_nature')->select('shop_articles.*','shop_article_natures.name as nature_name');
$model = $model::with('article_nature')->withCount(['categories', 'tags'])->joinRelationship('article_nature');
$model = self::filterByArticleNature($model);
return self::buildQuery($model);
}
@@ -30,8 +28,10 @@ class ArticlesDataTable extends DataTable
protected function getColumns()
{
return [
Column::make('article_nature.name')->data('nature_name')->title('Nature'),
Column::make('article_nature.name')->title('Nature'),
Column::make('name')->title('Nom'),
Column::make('tags_count')->title('Tags')->class('text-right'),
Column::make('categories_count')->title('Rayons')->class('text-right'),
self::makeColumnButtons(),
];
}