Add refreshing for inherited data

This commit is contained in:
Ludovic CANDELLIER
2021-08-30 22:59:50 +02:00
parent 0cd0e1f126
commit 8842b7eea7
10 changed files with 73 additions and 15 deletions

View File

@@ -3,18 +3,20 @@
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 $sortedColumn = 1;
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::joinRelations('Family')->select('shop_articles.*','shop_article_families.name as family_name');
// $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 = self::filterByArticleNature($model);
return self::buildQuery($model);
}
@@ -28,7 +30,7 @@ class ArticlesDataTable extends DataTable
protected function getColumns()
{
return [
Column::make('article_nature.name')->title('Nature')->orderable(false),
Column::make('article_nature.name')->data('nature_name')->title('Nature'),
Column::make('name')->title('Nom'),
self::makeColumnButtons(),
];