Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
27pchrisl committed Mar 22, 2024
1 parent d40be5c commit ae22e6c
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .idea/odata.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 17 additions & 15 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"ext-pdo_mysql": "*",
"ext-mongodb": "*",
"ext-redis": "*",
"ext-pdo_sqlite": "*"
"ext-pdo_sqlite": "*",
"staudenmeir/eloquent-json-relations": "^1.12"
},
"suggest": {
"league/csv": "To use the CSV entity set",
Expand Down
105 changes: 104 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions src/Drivers/EloquentEntitySet.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
use ReflectionClass;
use ReflectionException;
use ReflectionMethod;
use Staudenmeir\EloquentJsonRelations\Relations\BelongsToJson;
use Staudenmeir\EloquentJsonRelations\Relations\HasManyJson;

/**
* Eloquent Entity Set
Expand Down Expand Up @@ -555,21 +557,20 @@ public function discoverRelationship(
break;
}

if (!$localProperty || !$foreignProperty) {
throw new ConfigurationException(
'missing_properties',
'The properties referenced for the relationship could not be found on the models'
);
if ($localProperty && $foreignProperty) {
$referentialConstraint = new ReferentialConstraint($localProperty, $foreignProperty);
$navigationProperty->addConstraint($referentialConstraint);
}

$referentialConstraint = new ReferentialConstraint($localProperty, $foreignProperty);
$navigationProperty->addConstraint($referentialConstraint);
}

if ($relation instanceof BelongsTo || $relation instanceof HasOneThrough || $relation instanceof HasOne) {
$navigationProperty->setCollection(false);
}

if ($relation instanceof HasManyJson || $relation instanceof BelongsToJson) {
$navigationProperty->setCollection(true);
}

$binding = new NavigationBinding($navigationProperty, $right);

$this->getType()->addProperty($navigationProperty);
Expand Down

0 comments on commit ae22e6c

Please sign in to comment.