Reputation: 3
controller is
$scroll=true;
return view('frontgoso.index',compact('scroll'))->with('about',$about)->with('title',$title)-
>with('menu',$menu);
view is code here :
@foreach($menu as $row)
<li><a href="">{{$row->menu}}</a></li>
@endforeach
Upvotes: 0
Views: 42
Reputation:
If i understand your problem, this is solved with basic HTML (Anchor) and adding the target (point on page) to your $menu
-item.
@foreach($menu as $row)
<a href="#{{ $row->targetId }}">{{ $row->menu }}</a>
@endforeach
Then add an element with the same id as $row->targetId
:
<div id="ID-OF-TARGET-DIV">
My text...
</div>
You can also use Str::slug()
to create unique IDs from $row->menu
, assuming all rows are unique.
@foreach($menu as $row)
<a href="#{{ Str::slug($row->menu, '-') }}">{{ $row->menu }}</a>
@endforeach
You still have to add each id to an html element, how to do that depends on your full code.
Upvotes: 1