change last_nulls on mysql , is compatible with mariadb ?

This commit is contained in:
Ludovic CANDELLIER
2021-11-04 16:59:11 +01:00
parent 4761656405
commit 46b751c361
2 changed files with 7 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ class ArticlesDataTable extends DataTable
public function query(Article $model) 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); $model = self::filterByArticleNature($model);
return $this->buildQuery($model); return $this->buildQuery($model);
} }
@@ -28,9 +28,13 @@ class ArticlesDataTable extends DataTable
public function modifier($datatables) public function modifier($datatables)
{ {
$datatables->editColumn('thumb', function (Article $article) { $datatables
->editColumn('thumb', function (Article $article) {
return '<img src="' . Articles::getThumbSrc($article->image) . '">'; return '<img src="' . Articles::getThumbSrc($article->image) . '">';
}) })
->editColumn('article_nature.name', function (Article $article) {
return $article->article_nature ? $article->article_nature->name : '';
})
->rawColumns(['thumb', 'action']); ->rawColumns(['thumb', 'action']);
return parent::modifier($datatables); return parent::modifier($datatables);
} }

View File

@@ -67,7 +67,7 @@ return [
* Nulls last sql pattern for PostgreSQL & Oracle. * Nulls last sql pattern for PostgreSQL & Oracle.
* For MySQL, use 'CASE WHEN :column IS NULL THEN 1 ELSE 0 END, :column :direction' * 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. * User friendly message to be displayed on user if error occurs.