You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/app/Models/Traits/HasEnumFields.php
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -20,9 +20,13 @@ public static function getPossibleEnumValues($field_name)
20
20
21
21
$instance = newstatic(); // create an instance of the model to be able to get the table name
22
22
$connectionName = $instance->getConnectionName();
23
-
23
+
$connection = DB::connection($connectionName);
24
24
try {
25
-
$type = DB::connection($connectionName)->select(DB::raw('SHOW COLUMNS FROM `'.$table_prefix.$instance->getTable().'` WHERE Field = "'.$field_name.'"'))[0]->Type;
25
+
$select = app()->version() < 10 ?
26
+
DB::raw('SHOW COLUMNS FROM `'.$table_prefix.$instance->getTable().'` WHERE Field = "'.$field_name.'"') :
27
+
DB::raw('SHOW COLUMNS FROM `'.$table_prefix.$instance->getTable().'` WHERE Field = "'.$field_name.'"')->getValue($connection->getQueryGrammar());
28
+
29
+
$type = $connection->select($select)[0]->Type;
26
30
} catch (\Exception$e) {
27
31
abort(500, 'Enum field type is not supported - it only works on MySQL. Please use select_from_array instead.');
0 commit comments