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?
- Use
entity() method:
$repo->entity('users', function($entity){
return $entity->with('posts');
});
//$repo->entity is now $entity->with($users); (An instanceof Builder)
- 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]);
On L172 of Repofuck.php:
$this->entity = $this->entities->resolve($name);When
nullis supplied as the first argument inentity()method of Repofuck, it'll probably return the value of first element of$entitiessince in L172, nothing is supplied as the 2nd argument. Assuming that$entitiesofRepofuck's$entitiesis not empty. So$repo->entitywith have the first element resulted fromresolve().What if I want to do this?
entity()method:$entityofRepofuckwhich is now aBuilder,$repo->entitymust not be reset, the goal is that it must turn into:$entity->with('posts')->whereIn([1,2,3]);