Hello friends, I have a question about my project.
I'm building a laravel application based on independent microservices, but I'm having difficulty using laravel's native paginate to automatically paginate the results I receive from my api, below I leave an excerpt of my code:
....... MICRO SERVIÇO "ISSUES" ........
$query = Issue::query();
if ($search) {
$query->where('title', 'like', "%{$search}%");
}
$Issues = $query->paginate(10);
if ($Issues) {
return response()->json([
'status' => 'success',
'message' => "Issues successfully obtained",
'data' => $Issues
], 200);
}
...... MICRO SERVICE "FRONTEND" ......
$issues = Http::timeout(5)
->withToken($token)
->withHeaders([
'Accept' => 'application/json',
'Content-Type' => 'application/json',
])
->get(env('ISSUE_SERVICE_URL') . '/api/issues', [
'search' => $this->search
]);
if ($issues->successful()) {
$logout = Http::timeout(5)
->withHeaders([
'Accept' => 'application/json',
'Authorization' => "Bearer $token",
])
->post(env('USER_SERVICE_URL') . '/api/logout');
if ($logout->successful()) {
return view('livewire.issue-table', ['issues' => $issues]);
}
In short, the frontend microservice makes an http request to the issues microservice api, which in turn returns a response containing the data obtained from the database through eloquent already doing the pagination.
However, my difficulty is in making paging work in my view blade using the
{{ $issues->links() }}
I am having the error: Call to undefined method GuzzleHttp\Psr7\Response::links()
Could someone tell me what is wrong please?