Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class UserController extends Controller {
- public function __constructor(UserService $service, UserTransformer $transformer){
- $this->service = $service;
- $this->transformer = $transformer;
- }
- public function getPostsByUser(Request $request, NewRepository $newRepository, $userId){
- return $this->transformer->transformData($this->service->getUserPosts($userId, $newRepository));
- }
- }
- class UserService extends Service {
- public function __construct(UserRepository $repository){
- $this->repository = $repository;
- }
- public function getUserPosts($userId, NewRepository $newRepository){
- return $this->repository->getUserPostsFromRepository($userId, $newRepository);
- }
- }
- class UserRepository extends Repository {
- public function __construct(User $user){
- $this->model = $user;
- }
- public function getUserPostsFromRepository($id, $newRepository){
- return $newRepository->anotherMethod($this->model->with('posts')->find($id)->posts);
- }
- }
Add Comment
Please, Sign In to add comment