public static function getTableEnumList(string $field, string $labelKey = null, string $translationCode = null)
    {
        $type = DB::select(
            DB::raw('SHOW COLUMNS FROM ' . self::getTableName() . ' WHERE Field = "' . $field . '"')
        )[0]->Type;

        preg_match('/^enum\((.*)\)$/', $type, $matches);

        $values = [];

        foreach (explode(',', $matches[1]) as $value) {
            $value = trim($value, "'");

            if (is_null($labelKey)) {
                $values[] = $value;
            } else {
                $values[] = [
                    'id'      => $value,
                    $labelKey => trans($translationCode . $value),
                ];
            }
        }

        return $values;
    }
public static function getTableEnumList(string $field, string $labelKey = null, string $translationCode = null)
    {
        $type = DB::select(
            DB::raw('SHOW COLUMNS FROM ' . self::getTableName() . ' WHERE Field = "' . $field . '"')
        )[0]->Type;

        preg_match('/^enum\((.*)\)$/', $type, $matches);

        $values = [];

        foreach (explode(',', $matches[1]) as $value) {
            $value = trim($value, "'");

            if (is_null($labelKey)) {
                $values[] = $value;
            } else {
                $values[] = [
                    'id'      => $value,
                    $labelKey => trans($translationCode . $value),
                ];
            }
        }

        return $values;
    }
public static function getTableEnumList ( string $ field , string $ labelKey = null , string $ translationCode = null ) { $ type = DB :: select ( DB :: raw ( 'SHOW COLUMNS FROM ' . self :: getTableName ( ) . ' WHERE Field = "' . $ field . '"' ) ) [ 0 ] -> Type ; preg_match ( '/^enum\((.*)\)$/' , $ type , $ matches ) ; $ values = [ ] ; foreach ( explode ( ',' , $ matches [ 1 ] ) as $ value ) { $ value = trim ( $ value , "'" ) ; if ( is_null ( $ labelKey ) ) { $ values [ ] = $ value ; } else { $ values [ ] = [ 'id' => $ value , $ labelKey => trans ( $ translationCode . $ value ) , ] ; } } return $ values ; }
Get table enum field list with translations or not

@param string $field
@param null|string $labelKey
@param string $translationCode
@return array
Get table enum field list with translations or not