tailflow / laravel-orion

The simplest way to create REST API with Laravel

Home Page:https://orion.tailflow.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Filtering relationships with LIMIT

niels-hubs opened this issue · comments

Hi,

Curious, I have a chat model with messages. And for the chat overview screen I only want to have the latest message and to limit the amount of responses from that relation.

So I use the search operation, with a include, and a filter but I don't see a way to limit the amount of responses I get from that relation inside the search filters.

Is there a way to easily achieve this? In plain eloquent I can easily do this $query->latest()->take(5).

Kind regards,
Niels

Hi @niels-hubs,

Starting from v2.20.0 it is possible to provide limit field in a include relation descriptor to limit he number of included relation entities.