Skip to content

Commit

Permalink
fixed model relation 1:n (pick one) n:m (pick many)
Browse files Browse the repository at this point in the history
  • Loading branch information
eluhr committed Sep 7, 2021
1 parent 258bab4 commit acbe3b7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/generators/crud/providers/core/RelationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function activeField($attribute)
if (is_string($column)) {
return null;
}
$relation = $this->generator->getRelationByColumn($this->generator->modelClass, $column, ['belongs_to']);
$relation = $this->generator->getRelationByColumn($this->generator->modelClass, $column, ['belongs_to', 'has_one']);
if ($relation) {
switch (true) {
case !$relation->multiple:
Expand Down Expand Up @@ -128,7 +128,7 @@ public function attributeFormat($attribute)
//return null; #TODO: double check with primary keys not named `id` of non-pivot tables
}

$relation = $this->generator->getRelationByColumn($this->generator->modelClass, $column, ['belongs_to']);
$relation = $this->generator->getRelationByColumn($this->generator->modelClass, $column, ['belongs_to', 'has_one']);
if ($relation) {
if ($relation->multiple) {
return;
Expand Down Expand Up @@ -204,7 +204,7 @@ public function columnFormat($attribute, $model)
//return null;
}

$relation = $this->generator->getRelationByColumn($model, $column, ['belongs_to']);
$relation = $this->generator->getRelationByColumn($model, $column, ['belongs_to', 'has_one']);
if ($relation) {
if ($relation->multiple) {
return;
Expand Down

0 comments on commit acbe3b7

Please sign in to comment.