dimanche 20 décembre 2020

How to add offset after sortBy in laravel

How can I add offset after using sortBy in laravel? Please see my code below.

Controller

$order_type = ($dir == 'asc') ? 'sortBy' : 'sortByDesc';

$inventories = $inventories->get()->$order_type(function($inventory) {
   $item_status = [
     '0'  => 'I',
     '1'  => 'D',
     '2' => 'HI',
     '3' => 'HR',
     '4' => 'A',
     '5' => 'DS'
   ];

   return $item_status[$inventory->receive_item->inspection_status];
});

$inventories = $inventories->offset($start)->limit($limit);

Error I get

BadMethodCallException in Macroable.php line 74: Method offset does not exist.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire