Merge branch 'master' of https://git.mcnd.ca/mcndave/ulmus
This commit is contained in:
commit
6f558f2923
19 files changed
+592
-264
No files matched your search
+10
-3
@@ -110,6 +110,10 @@ trait EntityTrait {
|
||||
$bridgeRelation = $bridgeEntity->searchFieldAnnotation($relation->field, new Relation() );
|
||||
$relationRelation = $bridgeEntity->searchFieldAnnotation($relation->foreignField, new Relation() );
|
||||
|
||||
if ($relationRelation === null) {
|
||||
throw new \Exception("@Relation annotation not found for field `{$relation->foreignField}` in entity {$relation->bridge}");
|
||||
}
|
||||
|
||||
$repository = $relationRelation->entity()->repository();
|
||||
|
||||
$bridgeAlias = uniqid("bridge_");
|
||||
@@ -326,9 +330,9 @@ trait EntityTrait {
|
||||
/**
|
||||
* @Ignore
|
||||
*/
|
||||
public function toCollection() : array
|
||||
public function toCollection() : EntityCollection
|
||||
{
|
||||
return new EntityCollection($this->toArray());
|
||||
return static::entityCollection([ $this->toArray() ]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -382,7 +386,10 @@ trait EntityTrait {
|
||||
*/
|
||||
public static function entityCollection(...$arguments) : EntityCollection
|
||||
{
|
||||
return new EntityCollection(...$arguments);
|
||||
$collection = new EntityCollection(...$arguments);
|
||||
$collection->entityClass = static::class;
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user