casper / permission
Extend toddish verify permission to easy setting for Laravel 4.
dev-master
2014-02-11 13:19 UTC
Requires
- php: >=5.3.0
- illuminate/support: 4.*
- toddish/verify: 2.*
This package is auto-updated.
Last update: 2024-12-14 06:47:33 UTC
README
It's a extend toddish verify permission to easy setting for Laravel 4.
- a file organize all permission defined
- Licensed under the MIT license
Important
This packages depends on toddish/veirfy. You should configurate toddish/verify.
Installation
Add verify to your composer.json file:
"require": {
"casper/permission": "dev-master"
}
Now, run a composer update on the command line from the root of your project:
composer update
Registering the Package
Add the service provider to your config in app/config/app.php
:
'providers' => array( 'Casper\Permission\PermissionServiceProvider' ),
Set Package Aliases
Add the service Aliases to your config in app/config/app.php
:
'aliases' => array( 'Permission' => 'Casper\Permission\PermissionFacade' ),
Usage
1. Define permissions in app/permission.php
Now, create a file called app/permission.php
. The file will be loaded automatically.
// Permission::setPermission($route, $canUsePermissionName); Permission::setPermission(array('admin.roles.index', 'admin.roles.show'), array('role_index', 'role_all'));
As you can see, the define include two param:
$route
It's router name. It's can be array or string.$canUsePermissionName
It's means can use this page's permission name. It's can be array or string.
2. Run Verify
In you want to run verify place to add code:
Permission::verify(Request::url());
Example:
I want to verify after checking admin logged-in. So I place code in app/filters.php
Route::filter('auth.admin', function(){ if(Auth::guest()) return Redirect::route('admin.login'); // Permission Verify Permission::verify(); });