Answer the question
In order to leave comments, you need to log in
What is the best way to assemble a view with data from several models?
There is a small blog site on Laravel. Models Post and Comment, and respectively. PostsController and CommentController I show
the main page through the index method
$posts = Post::all();
return view('blog.index', compact('posts'));
return $post ? view('blog.show_post', compact('post')) : abort(404);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question