@automica thanks for the post count, it is fine.
And here I did not cleary about the pages. Posting again about the same...actually the function above is different and the loop coming from a different function which is index. So making things clear again here...
I am using resource in route:
Route::resource('categories', 'CategoryController', ['except' => ['create']]);
I have LinkController here:
public function index()
{
$links = Link::paginate(5);
$categories = Category::all();
return view('list', compact('links', 'categories'));
}
And CategoryController is this:
public function show(Category $category)
{
//$category = $category->links;
return view('category', compact('category'));
}
And list.blade.php page where the foreach loop is used as in the previous post. Now I have changed it to this one:
<ul class="list-group">
@foreach ($categories as $category)
<a class="list-group-item d-flex justify-content-between align-item-center" href="{{route('categories.show', $category->id)}}">{{$category->name}} <span class="badge-info badge-pill">{{$category->links()->count()}}</span></a>
@endforeach
</ul>
I want to set the link in this list.blade.php file which will show the post according to category. So I have created category page and it is added on CategoryCotroller. But this category page shows 404 error...whats is the mistake there...
I have not added anything on category page, just a title and trying to get the category name.