Skip to content

Commit af66075

Browse files
toitzisoyuka
andauthored
fix(laravel): fix foregin keys (relations) beeing in attributes (#6843)
* fix(laravel): fix foregin keys (relations) beeing in attributes Closes: #6842 Signed-off-by: Tobias Oitzinger <[email protected]> * cs fixes --------- Signed-off-by: Tobias Oitzinger <[email protected]> Co-authored-by: soyuka <[email protected]>
1 parent 2897c4f commit af66075

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Laravel/Eloquent/Metadata/ModelMetadata.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,14 @@ 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)
73+
->reject(
74+
fn ($column) => $relations->contains(
75+
fn ($relation) => $relation['foreign_key'] === $column['name']
76+
)
77+
)
7278
->map(fn ($column) => [
7379
'name' => $column['name'],
7480
'type' => $column['type'],

0 commit comments

Comments
 (0)