From 41cab61bda8a876516d0efddf309802def48a8dc Mon Sep 17 00:00:00 2001 From: Ludovic CANDELLIER Date: Thu, 4 Nov 2021 16:59:11 +0100 Subject: [PATCH] change last_nulls on mysql , is compatible with mariadb ? --- app/Datatables/Shop/ArticlesDataTable.php | 8 ++++++-- config/datatables.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Datatables/Shop/ArticlesDataTable.php b/app/Datatables/Shop/ArticlesDataTable.php index 3b45b4fe..3e0e2862 100644 --- a/app/Datatables/Shop/ArticlesDataTable.php +++ b/app/Datatables/Shop/ArticlesDataTable.php @@ -15,7 +15,7 @@ class ArticlesDataTable extends DataTable public function query(Article $model) { - $model = $model::with(['article_nature', 'image'])->withCount(['categories', 'tags', 'offers'])->joinRelationship('article_nature'); + $model = $model::with(['article_nature', 'image'])->withCount(['categories', 'tags', 'offers']); $model = self::filterByArticleNature($model); return $this->buildQuery($model); } @@ -28,9 +28,13 @@ class ArticlesDataTable extends DataTable public function modifier($datatables) { - $datatables->editColumn('thumb', function (Article $article) { + $datatables + ->editColumn('thumb', function (Article $article) { return ''; }) + ->editColumn('article_nature.name', function (Article $article) { + return $article->article_nature ? $article->article_nature->name : ''; + }) ->rawColumns(['thumb', 'action']); return parent::modifier($datatables); } diff --git a/config/datatables.php b/config/datatables.php index ed2e36f7..876e7520 100644 --- a/config/datatables.php +++ b/config/datatables.php @@ -67,7 +67,7 @@ return [ * Nulls last sql pattern for PostgreSQL & Oracle. * For MySQL, use 'CASE WHEN :column IS NULL THEN 1 ELSE 0 END, :column :direction' */ - 'nulls_last_sql' => ':column :direction NULLS LAST', + 'nulls_last_sql' => 'CASE WHEN :column IS NULL THEN 1 ELSE 0 END, :column :direction', /* * User friendly message to be displayed on user if error occurs.