diff --git a/src/Coders/Model/Factory.php b/src/Coders/Model/Factory.php index d3ffdece..10792f0f 100644 --- a/src/Coders/Model/Factory.php +++ b/src/Coders/Model/Factory.php @@ -458,8 +458,8 @@ protected function body(Model $model) $body .= $this->class->method($mutation->name(), $mutation->body(), ['before' => "\n"]); } - foreach ($model->getRelations() as $constraint) { - $body .= $this->class->method($constraint->name(), $constraint->body(), ['before' => "\n"]); + foreach ($model->getRelations() as $k => $constraint) { + $body .= $this->class->method(Str::camel($k), $constraint->body(), ['before' => "\n"]); } // Make sure there not undesired line breaks diff --git a/src/Coders/Model/Model.php b/src/Coders/Model/Model.php index 25c03849..a1af9a49 100644 --- a/src/Coders/Model/Model.php +++ b/src/Coders/Model/Model.php @@ -232,7 +232,7 @@ protected function fill() foreach ($this->blueprint->relations() as $relation) { $model = $this->makeRelationModel($relation); $belongsTo = new BelongsTo($relation, $this, $model); - $this->relations[$belongsTo->name()] = $belongsTo; + $this->relations[implode('_', $relation->get('columns'))] = $belongsTo; } foreach ($this->factory->referencing($this) as $related) {