File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
src/Laravel/Eloquent/Metadata Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff 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
71- return collect ($ columns )
72- ->map (fn ($ column ) => [
72+ $ collection = collect ($ columns )
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 ' ],
@@ -83,6 +89,8 @@ public function getAttributes(Model $model): Collection
8389 'primary ' => $ this ->isColumnPrimaryKey ($ indexes , $ column ['name ' ]),
8490 ])
8591 ->merge ($ this ->getVirtualAttributes ($ model , $ columns ));
92+
93+ return $ collection ;
8694 }
8795
8896 /**
You can’t perform that action at this time.
0 commit comments