解决 N+1 的问题

This commit is contained in:
iVampireSP.com 2022-11-21 13:01:23 +08:00
parent 89d776ddfe
commit ec4f3bcfe5
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -13,14 +13,12 @@ class HostController extends Controller
/**
* Display a listing of the resource.
*
* @param Host $host
*
* @return View
*/
public function index(Host $host): View
public function index(): View
{
$host->load('user');
$hosts = $host->paginate(50);
$hosts = Host::with('user')->paginate(100);
return view('admin.hosts.index', compact('hosts'));
}