Here is my UserController@getIndex, it output some users and all user count.
$name = Input::get('name');
$page = Input::get('page');
$limit = Input::get('limit');
$users = User::where('name', 'like', '%'.$name.'%')
->orderBy('created_at', 'desc')
->skip($limit*$page)->take($limit)
->get();
return array(
'rows'=>$users->toArray(),
'results'=>User::where('name', 'like', '%'.$name.'%')->count(),
);
Is there any way I can reuse the 'where()' part so I don't have to repeat my self?