#Klink
A simple way to manage active menu items
composer require kilroyweb/klink
In config/app.php 'providers':
KilroyWeb\Klink\KlinkServiceProvider::class,
In config/app.php 'facades':
'Klink'=> KilroyWeb\Klink\Facades\Klink::class,
Klink must start with the "url" method, from there options can be added as needed
<ul>
{!! Klink::url('my-account')->label('My Account') !!}
{!! Klink::url('logout')->label('Logout') !!}
</ul>
Results (If on /my-account page)
<ul>
<li class="active"><a href="http://localhost/my-account">My Account</a></li>
<li><a href="http://localhost/logout">Logout</a></li>
</ul>
{!! Klink::url('my-account')->label('My Account')->container(false) !!}
{!! Klink::url('my-account')->label('My Account')->container('h3') !!}
Results
<a href="http://localhost/my-account">My Account</a>
<h3><a href="http://localhost/my-account">My Account</a></h3>
Or when on the "my-account" page:
<a href="http://localhost/my-account" class="active" >My Account</a>
<h3 class="active"><a href="http://localhost/my-account">My Account</a></h3>
{!! Klink::url('my-account')->alsoCheck(['/profile', '/'])->label('My Account') !!}
Results (when on the /profile, /, or /my-account pages)
<h3 class="active"><a href="http://localhost/my-account">My Account</a></h3>
Sometimes you have a custom link where you just need to set the class as active:
<ul>
<li class="{!! Klink::url('my-account')->showClass() !!}"><a href="http://homestead.app/packages/klink/public/my-account">My Account</a></li>
</ul>
Will return class="active"
on the my-account page, otherwise will return empty class=""