0

I am using repository package to make API with laravel.I use transformers to transform data.It works well. I am wondering how can I use includes with transformers. As a example I have user class.I want to include UserBook model in User transformers.

I added following code to UserTransformer

protected $defaultIncludes = [
    'user_books',
];

 public function includeUserBooks(User $user){
        $project_books = $user->userBooks;

        return $project_books;
    }

But it is not return include.How can I call it through controller ?

Thank you.

IshaS
  • 837
  • 1
  • 10
  • 31

0 Answers0