php - Laravel: paginating a fluent query -


i'm trying paginate page in view this:

@foreach($tasks $task)     {{ $task->user_id }}     {{ $task->client_id }}     {{ $task->description }}     {{ $task->duration }}     {{ link_to_route('clients.show', 'view client', array($task->client_id), array('class' => 'btn btn-primary')) }} @endforeach     {{ $tasks->links() }} 

using following query in controller:

$tasks = db::table('tasks')     ->join('users', 'tasks.user_id', '=', 'users.id')     ->join('clients', 'tasks.client_id', '=', 'clients.id')     ->select(array('tasks.description', 'tasks.duration', 'tasks.client_id', 'tasks.user_id', 'users.email', 'clients.name'))     ->where('tasks.group_id', '=', $usergroup)     ->orderby('tasks.created_at', 'desc')     ->paginate(20);      return view::make('tasks.index', compact('tasks')); 

it shows tasks fine there's no pagination link showing can't head on next batch of 20 results.

any ideas on how can make work?

i've tried @foreach($tasks->result $task) in view suggested in http://forums.laravel.io/viewtopic.php?id=4092 gives me error "undefined property: illuminate\pagination\paginator::$result"

for playing @ home - discovered answer this:

the compact function converting object array. change return view method to:

return view::make('tasks.index')->with('tasks', $tasks); 

and you're in clear!

another point - if you're using bootstrap 3 rc1 me you'll find pagination breaks because of way bs3 styles pagination - if have issue head on here solution: https://github.com/laravel/laravel/issues/2215

:)


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -