mrcodes

Hello, Please Laravel throws "Memory Size Exhausted" error on usage of get() or …

Wed 12 Sep, 2018 06:09 am

Hello, Please Laravel throws "Memory Size Exhausted" error on usage of get() or all() eloquent methods whether there are values in the db or not. But it gives expected result when I use the first() method. This is unsusual. Who can help?

E.g This 

    $transaction_history = Form::all(); // Produces the error
    dd($transaction_history);

or this

   $transaction_history = Form::get(); // Produces the error
   dd($transaction_history);

It's expected to product either null for no result or a collection of objects!

But this 

   $transaction_history = Form::first(); // Works fine

Comments

dhtml

Wed 12 Sep, 2018 04:17 pm

You need to use pagination so that you dont get all the form at once and exhaust your memory. Take a look at this place - https://laravel.com/docs/5.6/pagination