GodziLaravel's avatar

what value should limit param takes to show all ?

Hello

This is how I limit the number of results :

$companies = $companies->paginate($value);

my question is : is there any value to give it to $value to show all (no pagination)

0 likes
5 replies
jlrdw's avatar

If you don't want pagination,

$companies = $companies->get();

Or calc the number of pages and use that number.

Sinnbeck's avatar

You can limit without pagination like this (assuming $companies is a query builder or model instance)

$companies = $companies->limit($value)->get();
GodziLaravel's avatar

@sti3bas I created a traits :

(...)
                        }
                    }
                }
                $companies = $companies->paginate($this->limit);

                return $companies;

and I want to use it in another places without changing this traits .

So i'm looking to put something in $this->limit

Snapey's avatar
Snapey
Best Answer
Level 122

Using paginate is a slower way of doing it. Just use take() and insert a very large number when you want all

1 like

Please or to participate in this conversation.