got it:
Route::get('authors/{author:name}',function(User $author){ $posts = $author->posts()->paginate(20); return view('admin.posts.index',['posts'=>$posts]); })->name('authors');
the paginator is added in my route so it's no longer a collection.
I have a blade page with this code: {{$post->user_id ? $post->user->name : 'no name'}}
This is my route in web.php Route::get('authors/{author:name}',function(User $author){ return view('admin.posts.index',['posts'=>$author->posts]); })->name('authors');
This is my controller:
public function index()
{
$posts = Post::with(['categories', 'user', 'photo'])->filter()->paginate(20);
return view('admin.posts.index', compact('posts'));
}
Now when i remove the pagination the posts are filtered by author. But with the pagination not.
Any help appreciated.
got it:
Route::get('authors/{author:name}',function(User $author){ $posts = $author->posts()->paginate(20); return view('admin.posts.index',['posts'=>$posts]); })->name('authors');
the paginator is added in my route so it's no longer a collection.
Please or to participate in this conversation.