I have a project in laravel that has a table named phonebook
and this table has over 200M records.
I want to load this into view, so I tried making my own pagination (since the paginate() didn’t work out).
This is my phonebook index
method which loads the data:
public function index(Request $request)
{
$page = $request->query('page', 1);
$perPage = 10;
$skip = ($page - 1) * $perPage;
$contacts = ContactList::skip($skip)->take($perPage)->get();
$totalContacts = ContactList::count();
$totalPages = ceil($totalContacts / $perPage);
$exitCode = Artisan::call('contact:count', []);
if ($exitCode === 0) {
$output = Artisan::output();
$users = User::where('is_admin',0)->where('is_active',1)->get();
return view('admin.contacts', compact('output', 'contacts', 'page', 'totalPages','users'));
} else {
$errorMessage = "Failed to execute the command.";
dd($errorMessage);
}
}
Now when I try accessing the page I get the error:
504 Gateway Time-out
So what is wrong here? How can I properly load this data into blade?
New contributor
Diaran is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.