digithis / activehelper
Active Helper 是为 Laravel 4 设计的一个简单的链接激活状态系统
dev-master
2013-11-21 08:57 UTC
Requires
- php: >=5.3.0
- illuminate/support: 4.*
This package is not auto-updated.
Last update: 2024-09-23 15:56:19 UTC
README
##Active Helper active helper 是为 Laravel 4 设计的一个简单的链接激活状态系统 ###如何安装 在你的 composer.json
中添加以下行
"digithis/activehelper": "dev-master"
然后运行 composer update
在 app/config/app.php
的 providers
数组中添加以下行
'Digithis\Activehelper\ActivehelperServiceProvider',
在 aliases
数组中添加以下行
'Active' => 'Digithis\Activehelper\ActiveFacade',
###如何使用 创建一个链接及其当前状态
echo Active::link('users', URL::to('users'), 'Show all users');
这意味着如果当前请求是 users
,链接的类将是 .active
将更多的路由作为第一个参数添加
echo Active::link(array('users', 'user/add', 'user/edit'), URL::to('users'), 'Show all users');
使用 *
作为模式或使用 not:
排除路由
echo Active::link(array('user*','not:user/edit'), URL::to('users'), 'Show all users');
这意味着如果请求以 user
开头但不是 user/edit
,链接的类将是 .active
如果你愿意,可以设置自己的属性
echo Active::link(array('group*','not:groups*'), URL::to('group'), 'Show group', array('id' => 'mycustomid'));
你也可以只获取当前状态(布尔值)
$state = Active::is('page*','not:pages*');
如果路由匹配,则返回激活的类
Active::classes('page*', 'not:pages*'); // Returns 'active'