3

I want to use the switch before using paginate. But am getting this error in my view -

Call to undefined method Illuminate\Database\Eloquent\Builder::links().

My Code - MyController.php

$var = User::select('somefield', 'anotherfield');

switch($condition){
   case foo:
       $var->where('bar', '=', 'xyz');
   break;
   case etc:
       $var->where('bar', '=', 'abc')
   break;
}
$var->paginate(10);
return View::make('x.y.z', compact('var'));
aminography
  • 21,986
  • 13
  • 70
  • 74
Piyush
  • 62
  • 14

1 Answers1

8

You need to catch in some variable as,

$data = $var->paginate(10);
return View::make('x.y.z', compact('data'));

In your current code, you are not saving paginated result anywhere.

Rahul
  • 18,271
  • 7
  • 41
  • 60