K
Size: a a a
K
И
public function index($slug){
$category = Category::select('id','title', 'slug')
->where('slug', $slug)
->first();
if (is_null($category)) {
abort(404);
}
$posts = Post::select('id', 'title', 'counter','category_id', 'created_at')
->where('category_id', $category->id)
->orderBy('created_at', 'DESC')
->paginate(7);
return view('category.index', compact('posts', 'category'));
}
IV
K
K
VR
K
И
AI
AI
VR
AI
K
И
VR
AI
И
$comments = App\Post::find(1)->comments;
foreach ($comments as $comment) {
//
}
K
$category = Category::select('id','title', 'slug')
->where('slug', $slug)
->with('post')
->first();
AI