I am implementing a repository pattern in Laravel and have a question about the implementation.
For example, I can make UserRepository
class have methods which follow Eloquent
standard:
public function create(array $properties)
{
return $this->entity->create($properties);
}
public function update($id, array $properties)
{
return $this->find($id)->update($properties);
}
public function delete($id)
{
return $this->find($id)->delete();
}
And then inject that repository where ever I need to do something with my user.
The problem I see here is...what happens in the back when I do for example:
$this->userRepository->authenticatedUser()->posts
Does this violate having the repository pattern if the posts
relation is called through Eloquent
then?
Does having a "real" repository pattern mean then to handle all possible relations which are loaded through the User
model?