Skip to content

Commit 192e679

Browse files
committed
fix(laravel): fix foregin keys (relations) beeing in attributes
Closes: #6842 Signed-off-by: Tobias Oitzinger <[email protected]>
1 parent 2d59c63 commit 192e679

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Laravel/Eloquent/Metadata/ModelMetadata.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,15 @@ public function getAttributes(Model $model): Collection
6767
$table = $model->getTable();
6868
$columns = $schema->getColumns($table);
6969
$indexes = $schema->getIndexes($table);
70+
$relations = $this->getRelations($model);
7071

7172
return collect($columns)
72-
->map(fn ($column) => [
73+
->reject(
74+
fn($column) => $relations->contains(
75+
fn($relation) => $relation['foreign_key'] === $column['name']
76+
)
77+
)
78+
->map(fn($column) => [
7379
'name' => $column['name'],
7480
'type' => $column['type'],
7581
'increments' => $column['auto_increment'],

0 commit comments

Comments
 (0)