Skip to content

Commit 6a1e891

Browse files
committed
fix db raw
1 parent 5772c57 commit 6a1e891

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/app/Models/Traits/HasEnumFields.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ public static function getPossibleEnumValues($field_name)
2020

2121
$instance = new static(); // create an instance of the model to be able to get the table name
2222
$connectionName = $instance->getConnectionName();
23-
23+
$connection = DB::connection($connectionName);
2424
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;
2630
} catch (\Exception $e) {
2731
abort(500, 'Enum field type is not supported - it only works on MySQL. Please use select_from_array instead.');
2832
}

0 commit comments

Comments
 (0)