diff --git a/src/Concerns/InteractsWithDbSchema.php b/src/Concerns/InteractsWithDbSchema.php index f1d91b3..dcf75e2 100644 --- a/src/Concerns/InteractsWithDbSchema.php +++ b/src/Concerns/InteractsWithDbSchema.php @@ -20,7 +20,7 @@ protected function getAllTableNames(): Collection } /** - * @return \Illuminate\Support\Collection> + * @return \Illuminate\Support\Collection> */ protected function getTableColumns(string $table, bool $withProperties = false): Collection { @@ -36,7 +36,7 @@ protected function getTableColumns(string $table, bool $withProperties = false): /** * @param array $exclude - * @return \Illuminate\Support\Collection> + * @return \Illuminate\Support\Collection> */ protected function getTableColumnsForRelation(string $table, array $exclude = []): Collection { @@ -68,7 +68,7 @@ protected function isFieldNullable(array $fieldProperties): bool } /** - * @return Collection> + * @phpstan-ignore-next-line */ private function replaceJsonColumnsSqliteWorkaround(string $table): Collection { @@ -76,11 +76,12 @@ private function replaceJsonColumnsSqliteWorkaround(string $table): Collection return collect($results)->map(function ($column) use ($table) { $column_value = DB::table($table)->whereNotNull($column->name)->value($column->name); - if (Str::isJson($column_value)) { + + if (is_string($column_value) && is_array(json_decode($column_value, true))) { $column->type_name = $column->type = 'json'; } - return $column; + return (array) $column; }); } }