Mrtvac
304
5
Laravel

Eloquent API - different resource for different requests

Posted 1 year ago by Mrtvac

Hi,

Quick question. With current eloquent api resource features is it possible to make different resources for same model to return different values? Or maybe add some conditional to request so resource knows which data to send back?

For example, when I return json data to one call I want to include model ID in response, while in other call, I want to return all data from model except ID.

Thank you for replies.

Please sign in or create an account to participate in this conversation.