From eed3f8a50e647e77aaa8ad81b2bae0af95909785 Mon Sep 17 00:00:00 2001 From: Ajay Dwivedi Date: Tue, 17 Dec 2024 15:40:05 +0000 Subject: [PATCH] Fix #43 - wrong order of keys in hasMany and hasOne relations. --- src/ModelGenerator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ModelGenerator.php b/src/ModelGenerator.php index 7ab39ca..4c2f9c0 100644 --- a/src/ModelGenerator.php +++ b/src/ModelGenerator.php @@ -131,8 +131,8 @@ protected function getOtherRelations() 'name' => $isUniqueColumn ? 'hasOne' : 'hasMany', 'relation_name' => Str::camel($isUniqueColumn ? Str::singular($table) : Str::plural($table)), 'class' => Str::studly(Str::singular($table)), - 'foreign_key' => $relation['foreign_columns'][0], - 'owner_key' => $relation['columns'][0], + 'owner_key' => $relation['foreign_columns'][0], + 'foreign_key' => $relation['columns'][0], ]; } }