Reputation: 23
I need to paginate this where I need to find id but i don't know how.
function customerContact($id)
{
$customers = Customer::with('contacts')->find($id);
return Inertia::render('Customers/Contacts/Index', [
'customers' => $customers,
]);
}
Upvotes: 0
Views: 89
Reputation: 21
on the third line in the customerContact() function
$customers = Customer::with('contacts')->find($id);
change to
$customers = Customer::find($id)->contacts()->paginate();
Upvotes: 1
Reputation: 1091
Try this
$customers = Customer::find($id)->contacts()->paginate();
Upvotes: 4