[英]How to add paginate in laravel with relationship?
我需要在需要找到 id 的地方分頁,但我不知道如何。
function customerContact($id)
{
$customers = Customer::with('contacts')->find($id);
return Inertia::render('Customers/Contacts/Index', [
'customers' => $customers,
]);
}
嘗試這個
$customers = Customer::find($id)->contacts()->paginate();
在 customerContact() 的第三行 function
$customers = Customer::with('contacts')->find($id);
改成
$customers = Customer::find($id)->contacts()->paginate();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.