andersao / andersao/l5-repository

Limit result whitout paginate

Offen
#426 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
PHP
Sterne
4.2k
Forks
880
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Hello, Good Night,

How can I limit the result, lets say to the first 5 items without paginate...

example

a blog has it's posts, the main page have the posts paginated, but a sidebar has the last 5 items...
How can i get the sidebar items, if I use paginate it will get the results with pagination, i don't want to get all items and do a for...

I've tried
$this->repository->orderBy('created_at','DESC')->get(10);
$this->repository->orderBy('created_at','DESC')->first(10);
$this->repository->orderBy('created_at','DESC')->limit(10);

$this->repository->orderBy('created_at','DESC')->paginate(10); (This one returned with paginated items

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.