designbycode/laravel-helpers

This package is abandoned and no longer maintained. The author suggests using the https://github.com/DesignByCode/active-links package instead.

Simple laravel helper utilities

v2.0.2 2020-05-04 14:03 UTC

This package is auto-updated.

Last update: 2020-05-04 18:26:50 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock GitHub stars Twitter

Introduction to Laravel Helpers

Laravel helpers is a very simple utilities class that help with small things like settings classes to html elements.

Install with composer

$ composer require designbycode/laravel-helpers

Set an class of active for links

Set link for navigation to active on page.

<a href="{{ url('/') }}" class='{{ Set::isActive('/') }}'>Home</a>
or
<a href="{{ url('/') }}" class='{{ set_active('/') }}'>Home</a>

Add custom active classes or change the helpers config file for global changes.

<a href="{{ url('/') }}" class='{{ Set::isActive('/', 'active open' ) }}'>Home</a>
or
<a href="{{ url('/') }}" class='{{ set_active('/', 'active open') }}'>Home</a>

Set html body class to route name and route name with body prefix

// Example
// <body class="body body-home home">
<body class="{{ Set::bodyClass() }}">
    ...
<body class="{{ set_body() }}">
    ...

Classes can be added or remove passing 2 arrays. The first array will add classes and the second array will exclude classes.

<body class="{{ Set::bodyClass(['foo', 'bar'], ['body', 'foo-bar']) }}">
    ...
<body class="{{ set_body(['foo', 'bar'], ['body', 'foo-bar']) }}">
    ...

Config Helpers

Run the following command to publish config helpers to set global class names.

php artisan vendor:publish --provider=DesignByCode\Helpers\Providers\HelpersServiceProvider

License

Laravel UI is open-sourced software licensed under the MIT license.