Level 58
To paginate the results while loading the related user for a thread, you can use the with method instead of load. Here's an example:
return Inertia::render('Discussion/Threads/Index', [
'threads' => Thread::with('user')->latest()->paginate(20)
]);
This will load the related user for each thread and paginate the results. You can access the threads and pagination data in your view like this:
@foreach ($threads as $thread)
{{ $thread->title }}
{{ $thread->user->name }}
@endforeach
{{ $threads->links() }}