Reputation: 39
This is the blade view to create the url links
@section ('category')
<ul class="main-categories">
@foreach($category as $category)
<li class="main-nav-list"><a href="{{asset('/glassfilm')}}/{{$category->category}}">{{ $category->category }}<span class="number">{{ $category->count}}</span></a></li>
@endforeach
</ul>
@endsection
when i click for the first time it's working fine and the url I get is
when I click for the secon time the url I get is
what I am doing wrong?
Upvotes: 1
Views: 376
Reputation: 2945
asset()
method is used to include CSS/JavaScript/images files.
url()
method used to generate a URL to a link.
Laravel's route()
method is very helpful. So you can try:
<li class="main-nav-list"><a href="{{ route('glassfilm-category', ['name' => $category->category]) }}">{{ $category->category }}<span class="number">{{ $category->count}}</span></a></li>
@section ('category')
<ul class="main-categories">
@foreach($category as $category)
<li class="main-nav-list"><a href="{{ route('glassfilm-category', $category->category) }}">{{ $category->category }}<span class="number">{{ $category->count}}</span></a></li>
@endforeach
</ul>
@endsection
Upvotes: 2
Reputation: 5731
Change your route as below :
@section ('category')
<li class="main-nav-list">
<a href="{{ route('glassfilm-category',['name' => $category->category]) }}"> {{ $category->category }}
<span class="number">{{ $category->count}}</span>
</a>
</li>
@endsection
Upvotes: 2