public function index(Tag $tag){
//$posts=$tag->posts;
$posts=$tag->posts->paginate(10);
return view('posts.index' , compact('posts'));
}
Use relationship, not property:
$tag->posts()->paginate(10);
When you're using property, the query is already executed and you can't use the paginate()
method on a collection.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加