Skip to content

On modifying the Repofuck's current entity with Closure #119

@makoru-hikage

Description

@makoru-hikage

On L172 of Repofuck.php:

$this->entity = $this->entities->resolve($name);

When null is supplied as the first argument in entity() method of Repofuck, it'll probably return the value of first element of $entities since in L172, nothing is supplied as the 2nd argument. Assuming that $entities of Repofuck's $entities is not empty. So $repo->entity with have the first element resulted from resolve().

What if I want to do this?

  1. Use entity() method:
$repo->entity('users', function($entity){
    return $entity->with('posts');
});
//$repo->entity is now $entity->with($users); (An instanceof Builder)
  1. Append some method calls to the current $entity of Repofuck which is now a Builder, $repo->entity must not be reset, the goal is that it must turn into:

$entity->with('posts')->whereIn([1,2,3]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions