I'm trying to return a pagination from the controller using the link function, but I return an empty value. What could be the problem?
$models= Model::with('table2', 'table3')
->simplePaginate(5);
$str= "";
foreach($models as model){
$str .= model['name'];
}
return response()->json([
'rows' => $str,
'links' => $models->links()
], 200);
laravel 5.5
If I return
return $models->appends(['rows' => $str])->links();
I get what I want. But when you try to return an array or a json, the link is empty