When learning the basics of Laravel I implemented this tip
Laravel Quick Tip – get previous / next records
to make "go to next/previous records.
// get next user id
$next = Model::where('id', '>', $object->id)->min('id');
$next = Model::find($next);
and then in my view file:
<a href="{{ URL::to( 'models/' . join('-', [$next->id, $next->slug]) ) }}" class="ui button nav">
GO TO NEXT
I have put this code into all controllers with show() action. It works, but it doesn't look as a good practice.
My question:
Can we make a helper for these links, please?
Peter
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire