44
55use Backpack \CRUD \ViewNamespaces ;
66use Carbon \Carbon ;
7- use Doctrine \DBAL \Types \JsonType ;
87use Validator ;
98
109trait Search
@@ -113,7 +112,7 @@ public function applyDatatableOrder()
113112 if (method_exists ($ this ->model , 'translationEnabled ' ) &&
114113 $ this ->model ->translationEnabled () &&
115114 $ this ->model ->isTranslatableAttribute ($ column ['name ' ]) &&
116- is_a ( $ this ->model -> getConnection ()-> getDoctrineColumn ( $ this -> model -> getTableWithPrefix (), $ column ['name ' ])-> getType (), JsonType::class )
115+ $ this ->isJsonColumnType ( $ column ['name ' ])
117116 ) {
118117 $ this ->orderByWithPrefix ($ column ['name ' ].'-> ' .app ()->getLocale (), $ column_direction );
119118 } else {
@@ -395,10 +394,10 @@ public function getEntriesAsJsonForDatatables($entries, $totalRows, $filteredRow
395394 }
396395
397396 return [
398- 'draw ' => (isset ($ this ->getRequest ()['draw ' ]) ? (int ) $ this ->getRequest ()['draw ' ] : 0 ),
399- 'recordsTotal ' => $ totalRows ,
397+ 'draw ' => (isset ($ this ->getRequest ()['draw ' ]) ? (int ) $ this ->getRequest ()['draw ' ] : 0 ),
398+ 'recordsTotal ' => $ totalRows ,
400399 'recordsFiltered ' => $ filteredRows ,
401- 'data ' => $ rows ,
400+ 'data ' => $ rows ,
402401 ];
403402 }
404403
@@ -413,4 +412,9 @@ public function getColumnWithTableNamePrefixed($query, $column)
413412 {
414413 return $ query ->getModel ()->getTable ().'. ' .$ column ;
415414 }
415+
416+ private function isJsonColumnType (string $ columnName )
417+ {
418+ return $ this ->model ->getDbTableSchema ()->getColumnType ($ columnName ) === 'json ' ;
419+ }
416420}
0 commit comments