Skip to content

Lack one reference method when two FKs in a table references to a same table #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Coders/Model/Factory.php
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/Coders/Model/Model.php
Original file line number Diff line number Diff line change
@@ -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) {