I have 2 methods with eager loading and paginate. but problem is that i have to use where constraint too and i am getting offset 0 error.
public function showAllOrders(){
$orders = \admin\Order::with('orderfiles','paymentStatus','orderStatus','orderDelivery','flexibleDelivery')->paginate(20);
return View('admin.all_orders')
->with('orders',$orders);
}
public function showAllPaidOrders(){
$orders = \admin\Order::with(array('orderfiles','orderStatus','orderDelivery','flexibleDelivery','paymentStatus'=>function($query){
$query->where('status', '=', 'Paid');
}))->paginate(20);
return View('admin.all_orders')
->with('orders',$orders);
}
showAllOrders working fine but when i am using where constraint with showAllPaidOrders i am getting offset error....
1/2 ErrorException in Collection.php line 837: Undefined offset: 0 2/2 ErrorException in Collection.php line 837: Undefined offset: 0 (View: E:\content\xampp\htdocs\l5esources\views\admin\all_orders.blade.php)
Even if both blade views are same. The only difference is the "Where Constraint"