All Projects → dwightwatson → Active

dwightwatson / Active

Licence: mit
Laravel helper for recognising the current route, controller and action.

Labels

Projects that are alternatives of or similar to Active

Laravel Setting
Persistent settings package for Laravel
Stars: ✭ 278 (-4.79%)
Mutual labels:  laravel
Laravel Apidoc Generator
Laravel API Documentation Generator
Stars: ✭ 3,170 (+985.62%)
Mutual labels:  laravel
Laravel Google Translate
Translate translation files to other languages using google translate or another translation api
Stars: ✭ 287 (-1.71%)
Mutual labels:  laravel
Resources I Like
📚💯 Collection of learning resources i like
Stars: ✭ 280 (-4.11%)
Mutual labels:  laravel
Laravel Gymie
👨‍💻 Gym & Club Management System https://gymie.in
Stars: ✭ 285 (-2.4%)
Mutual labels:  laravel
Laravel Websockets Demo
Demo application to use with the Laravel WebSockets package.
Stars: ✭ 286 (-2.05%)
Mutual labels:  laravel
Laravel Achievements
Achievements for Laravel 5.3+
Stars: ✭ 279 (-4.45%)
Mutual labels:  laravel
Laravel Varnish
Making Varnish and Laravel play nice together
Stars: ✭ 291 (-0.34%)
Mutual labels:  laravel
Stripe Laravel
Cartalyst Stripe package integration for Laravel.
Stars: ✭ 286 (-2.05%)
Mutual labels:  laravel
Laravel Vue Admin
开箱即用的Laravel后台扩展,前后端分离,后端控制前端组件,无需编写vue即可创建一个vue+vuex+vue-route+elment-ui+laravel的项目 ,丰富的表单 表格组件,强大的自定义组件功能。
Stars: ✭ 287 (-1.71%)
Mutual labels:  laravel
Tipask
Tipask是一款开放源码的PHP问答系统,基于Laravel框架开发,容易扩展,具有强大的负载能力和稳定性。
Stars: ✭ 282 (-3.42%)
Mutual labels:  laravel
Laravel Sign In With Apple
Provide "Sign In With Apple" functionality to your Laravel app.
Stars: ✭ 283 (-3.08%)
Mutual labels:  laravel
Laravel Deploy On Shared Hosting
The simple guide to deploy Laravel application to shared hosting services.
Stars: ✭ 288 (-1.37%)
Mutual labels:  laravel
Laravel Job Status
Add ability to track Job progress, status and result dispatched to Queue.
Stars: ✭ 279 (-4.45%)
Mutual labels:  laravel
Laravel Masterpass
Helps you securely setup a master password and login into user accounts with it.
Stars: ✭ 289 (-1.03%)
Mutual labels:  laravel
Laravel Starter Kit
Laravel 7.0~ Starter Kit Powered by VueJS + Material Design(Vuetify)
Stars: ✭ 281 (-3.77%)
Mutual labels:  laravel
Wookteam
WookTeam是一款轻量级的开源在线团队协作工具,提供各类文档协作工具、在线思维导图、在线流程图、项目管理、任务分发、即时IM,知识库管理等工具。
Stars: ✭ 287 (-1.71%)
Mutual labels:  laravel
Laravel Authentication Acl
Laravel authentication and ACL admin panel package based on sentry
Stars: ✭ 292 (+0%)
Mutual labels:  laravel
Laravel Livewire Tables
A dynamic table component for Laravel Livewire
Stars: ✭ 288 (-1.37%)
Mutual labels:  laravel
S Cart
Free Laravel open source e-commerce for business: shopping cart, cms content, and more...
Stars: ✭ 286 (-2.05%)
Mutual labels:  laravel

Active for Laravel

Build Status Total Downloads Latest Stable Version Latest Unstable Version License Buy us a tree

Active is a helper package for Laravel that makes it easy to recognize the current path or route, useful for adding 'active' classes (like those used in the Boostrap framework) and performing other actions only when a certain route is active. It also includes helpers for retrieving the current controller and action names.

Installation

First, simply require the package through Composer.

composer require watson/active

Using Laravel 5.1? The latest version of the package that will work for you is 2.0.4.

Next, add the service provider in your config/app.php file.

Watson\Active\ActiveServiceProvider::class

If you'd like to use the Facade instead of the helper functions, add it to the aliases array.

'Active' => Watson\Active\Facades\Active::class

Using Active

Helper functions

Active ships with a couple of helper functions which make it easy to use without the facade or creating an instance of your own.

active()
is_active()

Using active()

You pass an array of routes or paths you want to see are the current page, and if any match this function will return the string active, for Bootstrap. Alternatively, you can pass a custom return string as the second argument.

active(['login', 'users/*', 'posts.*', 'pages.contact']); // Returns 'active' if the current route matches any path or route name.

active(['login', 'logout'], 'active-class'); // Returns 'active-class' if the current route is 'login' or 'logout'.

active(['login', 'logout'], 'active-class', 'fallback-class'); // Returns 'fallback-class' if the current route is not 'login' or 'logout'.

In the first example, the function will return the string active if the current path is login, starts with users/ or if the name of the current route is posts.create.

Do note that a number of argument types are provided: you can use a path string, you can use a path string with a wildcard (using the *) and you can also use named routes.

You can use this function with your links to give them an active state.

<a href="{{ route('posts.index') }}" class="{{ active('posts.index') }}">All posts</a>

You can also provide certain paths or routes to be exluded when being considered.

active(['pages/*', 'not:pages/contact'])

active(['pages.*', 'not:pages.contact'])

Using is_active()

This works much the same as active(), you can pass the paths and routes to it but instead it will return a boolean if the current page matches.

@if (is_active('posts/*'))
    You're looking at a blog post!
@endif

Additional helpers

Two additional functions are provided to get the current controller and action, if your routing is being handled by a controller for a request. These functions will return the lowercase controller/action name, without the method of the request. Here is an example for a request that is routed to `[email protected]':

$controller = controller_name(); // foo

$action = action_name(); // bar

Licence

Active for Laravel is 100% free and open-source, under the MIT license. Use it however you want.

This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].