ellipsesynergie / api-response

Simple package to handle response properly in your API.
MIT License
377 stars 53 forks source link

set includes for response #38

Open naabster opened 7 years ago

naabster commented 7 years ago

I wonder if there is a nicer way to set includes for the response. I dont mean to parse the includes from include parameter, but set them "manually" for that response.

right now I am doing this (Laravel):

    $this->response->getManager()->parseIncludes('team');
    return $this->response->withItem($request->user(), new UserTransformer);

Maybe something like

    return $this->response->parseIncludes('team')->withItem($request->user(), new UserTransformer);

would be shorter and nicer. I could prepare a pull request if that's something you would like to integrate.

maximebeaudoin commented 7 years ago

@naabster Hi, i think something like $this->response->includes('team')->withItem($request->user(), new UserTransformer); could be a good format. If you want, you can create a PR for that.

Thank you.