ahmedsami's avatar

item has many relations get pagination links

i have 2 model category model and topics model category has many topics and while i get the category relation (topics) pagination it works good but how to get the pagination links ?

this is my code and it works well $category->load([ 'topics' => function($query){ return $query->paginate(2); }]);

but this is not workin :( $category->topics()->links()

0 likes
2 replies
Respect's avatar
// Try This 
$topics = $category->topics()->paginate(2);

// to show the links 
{{ $topics->links() }}
// OR i'm not sure with eager load || U have to refrance realtionship in $var
$topics = $category->load([ 'topics' => function($query){ 
        return $query->paginate(2); 
}]);

// to show the links 
{{ $topics->links() }}
1 like
ahmedsami's avatar

thanks , it works this fist one just to show the pagination the sec one , no

Please or to participate in this conversation.