PHPackages                             ipunkt/permissions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. ipunkt/permissions

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

ipunkt/permissions
==================

1 line permission checks for laravel 4.x

1.0rc1(11y ago)41261MITPHPPHP &gt;=5.4.0

Since Sep 24Pushed 11y ago5 watchersCompare

[ Source](https://github.com/ipunkt/permissions)[ Packagist](https://packagist.org/packages/ipunkt/permissions)[ Docs](https://github.com/ipunkt/permissions)[ RSS](/packages/ipunkt-permissions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (1)

ipunkt/permissions
==================

[](#ipunktpermissions)

Check your permissions with a simple 1-liner: `$user->can('do something', $onAnObject)`

About
=====

[](#about)

The goal of this package is to extract your permission checking code from both your controller and your model. Instead, each Model brings its own PermissionChecker object which then does the permission checking.

Install
=======

[](#install)

Installation
------------

[](#installation)

Add to your composer.json following lines

```
"require": {
	"ipunkt/permissions": "dev-master"
}

```

Configuration
-------------

[](#configuration)

Add

```
'Ipunkt\Permissions\PermissionsServiceProvider'

```

to your service provider list

Use
---

[](#use)

Have your Usermodel implement `CanInterface` and use `CanTrait`Have the Models you with to perform permission checks on implement `HasPermissionInterface` and use `HasPermissionTrait`

This will allow you to do `$user->can('doSomething', $model);`

### Simple use

[](#simple-use)

Pull in another package which handles permission management and set permissions through is.

Known packages which have ipunkt/permissions support out of the box:

- ipunkt/roles

### Dynamic Permissions

[](#dynamic-permissions)

Usualy, you do not want to create an individual role and permission per user to edit their own profile, even if you have a system to do so. To address this, you can switch out the PermissionChecker object for your models.

```
