diff --git a/README.md b/README.md index fd95559e..1d98310b 100644 --- a/README.md +++ b/README.md @@ -216,9 +216,16 @@ $admin->name = 'admin'; $admin->display_name = 'User Administrator'; // optional $admin->description = 'User is allowed to manage and edit other users'; // optional $admin->save(); + + +$edit_post = new Permission(); +$edit_post->name = 'edit_own_post'; +$edit_post->display_name = 'Can Edit Self Created Post'; // optional +$edit_post->description = 'User is allowed to edit only his own posts'; // optional +$edit_post->save(); ``` -Next, with both roles created let's assign them to the users. +Next, with both roles and the new permission created let's assign them to the users. Thanks to the `HasRole` trait this is as easy as: ```php @@ -229,6 +236,12 @@ $user->attachRole($admin); // parameter can be an Role object, array, or id // or eloquent's original technique $user->roles()->attach($admin->id); // id only + +// permission attach alias +$user->attachPermission($edit_post); // parameter can be an Permission object, array, or id + +// or eloquent's original technique +$user->permission()->attach($edit_post->id); // id only ``` Now we just need to add permissions to those Roles: diff --git a/composer.lock b/composer.lock index ca3102dc..bac59410 100644 --- a/composer.lock +++ b/composer.lock @@ -4,37 +4,94 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "e6fcf53f8a08a77e7eb0af419689374f", + "hash": "58fedb308076ce14a851f4677e844b9f", + "content-hash": "370ad780cc81d4e83c18f8554926e39d", "packages": [ + { + "name": "danielstjules/stringy", + "version": "1.x-dev", + "source": { + "type": "git", + "url": "https://github.com/danielstjules/Stringy.git", + "reference": "4749c205db47ee5b32e8d1adf6d9aff8db6caf3b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/danielstjules/Stringy/zipball/4749c205db47ee5b32e8d1adf6d9aff8db6caf3b", + "reference": "4749c205db47ee5b32e8d1adf6d9aff8db6caf3b", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Stringy\\": "src/" + }, + "files": [ + "src/Create.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniel St. Jules", + "email": "danielst.jules@gmail.com", + "homepage": "http://www.danielstjules.com" + } + ], + "description": "A string manipulation library with multibyte support", + "homepage": "https://github.com/danielstjules/Stringy", + "keywords": [ + "UTF", + "helpers", + "manipulation", + "methods", + "multibyte", + "string", + "utf-8", + "utility", + "utils" + ], + "time": "2015-07-23 00:54:12" + }, { "name": "doctrine/inflector", - "version": "1.2.x-dev", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/doctrine/inflector.git", - "reference": "e11d84c6e018beedd929cff5220969a3c6d1d462" + "reference": "90b2128806bfde671b6952ab8bea493942c1fdae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/e11d84c6e018beedd929cff5220969a3c6d1d462", - "reference": "e11d84c6e018beedd929cff5220969a3c6d1d462", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/90b2128806bfde671b6952ab8bea493942c1fdae", + "reference": "90b2128806bfde671b6952ab8bea493942c1fdae", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=5.3.2" }, "require-dev": { - "phpunit/phpunit": "^6.2" + "phpunit/phpunit": "4.*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { - "psr-4": { - "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" + "psr-0": { + "Doctrine\\Common\\Inflector\\": "lib/" } }, "notification-url": "https://packagist.org/downloads/", @@ -71,36 +128,37 @@ "singularize", "string" ], - "time": "2017-07-22 12:18:28" + "time": "2015-11-06 14:35:42" }, { "name": "illuminate/cache", - "version": "5.5.x-dev", + "version": "5.0.x-dev", "source": { "type": "git", "url": "https://github.com/illuminate/cache.git", - "reference": "709f1c7da68b65421b3590f5258e158232f33836" + "reference": "f50da0fe0365ba7bcaa7cfa605db5bf7c9d3c9b9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/cache/zipball/709f1c7da68b65421b3590f5258e158232f33836", - "reference": "709f1c7da68b65421b3590f5258e158232f33836", + "url": "https://api.github.com/repos/illuminate/cache/zipball/f50da0fe0365ba7bcaa7cfa605db5bf7c9d3c9b9", + "reference": "f50da0fe0365ba7bcaa7cfa605db5bf7c9d3c9b9", "shasum": "" }, "require": { - "illuminate/contracts": "5.5.*", - "illuminate/support": "5.5.*", - "php": ">=7.0" + "illuminate/contracts": "5.0.*", + "illuminate/support": "5.0.*", + "nesbot/carbon": "~1.0", + "php": ">=5.4.0" }, "suggest": { - "illuminate/database": "Required to use the database cache driver (5.5.*).", - "illuminate/filesystem": "Required to use the file cache driver (5.5.*).", - "illuminate/redis": "Required to use the redis cache driver (5.5.*)." + "illuminate/database": "Required to use the database cache driver (5.0.*).", + "illuminate/filesystem": "Required to use the file cache driver (5.0.*).", + "illuminate/redis": "Required to use the redis cache driver (5.0.*)." }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.5-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -115,42 +173,43 @@ "authors": [ { "name": "Taylor Otwell", - "email": "taylor@laravel.com" + "email": "taylorotwell@gmail.com" } ], "description": "The Illuminate Cache package.", - "homepage": "https://laravel.com", - "time": "2017-09-19 17:21:01" + "homepage": "http://laravel.com", + "time": "2015-04-07 17:53:27" }, { "name": "illuminate/console", - "version": "5.5.x-dev", + "version": "5.0.x-dev", "source": { "type": "git", "url": "https://github.com/illuminate/console.git", - "reference": "d49110189092cfeae5950290ead77d403aa1372d" + "reference": "a1271fa68eed09a06b39fb60522b15f3a3551a23" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/console/zipball/d49110189092cfeae5950290ead77d403aa1372d", - "reference": "d49110189092cfeae5950290ead77d403aa1372d", + "url": "https://api.github.com/repos/illuminate/console/zipball/a1271fa68eed09a06b39fb60522b15f3a3551a23", + "reference": "a1271fa68eed09a06b39fb60522b15f3a3551a23", "shasum": "" }, "require": { - "illuminate/contracts": "5.5.*", - "illuminate/support": "5.5.*", - "php": ">=7.0", - "symfony/console": "~3.3" + "illuminate/contracts": "5.0.*", + "nesbot/carbon": "~1.0", + "php": ">=5.4.0", + "symfony/console": "2.6.*" }, "suggest": { - "guzzlehttp/guzzle": "Required to use the ping methods on schedules (~6.0).", + "guzzlehttp/guzzle": "Required to use the thenPing method on schedules (~5.0).", "mtdowling/cron-expression": "Required to use scheduling component (~1.0).", - "symfony/process": "Required to use scheduling component (~3.3)." + "nesbot/carbon": "Required to use scheduling component (~1.0).", + "symfony/process": "Required to use scheduling component (2.6.*)." }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.5-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -165,36 +224,34 @@ "authors": [ { "name": "Taylor Otwell", - "email": "taylor@laravel.com" + "email": "taylorotwell@gmail.com" } ], "description": "The Illuminate Console package.", - "homepage": "https://laravel.com", - "time": "2017-10-25 19:10:11" + "homepage": "http://laravel.com", + "time": "2015-05-28 22:24:21" }, { "name": "illuminate/contracts", - "version": "5.5.x-dev", + "version": "5.0.x-dev", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", - "reference": "d9e269284eba43bd2e9e8d1f1ba12362b00ec096" + "reference": "6d23815fee6057b29cab8094af8cbb8ce3ac82e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/contracts/zipball/d9e269284eba43bd2e9e8d1f1ba12362b00ec096", - "reference": "d9e269284eba43bd2e9e8d1f1ba12362b00ec096", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/6d23815fee6057b29cab8094af8cbb8ce3ac82e4", + "reference": "6d23815fee6057b29cab8094af8cbb8ce3ac82e4", "shasum": "" }, "require": { - "php": ">=7.0", - "psr/container": "~1.0", - "psr/simple-cache": "~1.0" + "php": ">=5.4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.5-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -209,46 +266,42 @@ "authors": [ { "name": "Taylor Otwell", - "email": "taylor@laravel.com" + "email": "taylorotwell@gmail.com" } ], "description": "The Illuminate Contracts package.", - "homepage": "https://laravel.com", - "time": "2017-09-19 13:09:37" + "homepage": "http://laravel.com", + "time": "2015-05-15 07:22:28" }, { "name": "illuminate/support", - "version": "5.5.x-dev", + "version": "5.0.x-dev", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "e97328afda4d93438e3ac1891d6594fdc851f5d6" + "reference": "28dcacacd2091c106e352db1732eda8c590914f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/e97328afda4d93438e3ac1891d6594fdc851f5d6", - "reference": "e97328afda4d93438e3ac1891d6594fdc851f5d6", + "url": "https://api.github.com/repos/illuminate/support/zipball/28dcacacd2091c106e352db1732eda8c590914f6", + "reference": "28dcacacd2091c106e352db1732eda8c590914f6", "shasum": "" }, "require": { - "doctrine/inflector": "~1.1", + "danielstjules/stringy": "~1.8", + "doctrine/inflector": "~1.0", "ext-mbstring": "*", - "illuminate/contracts": "5.5.*", - "nesbot/carbon": "^1.20", - "php": ">=7.0" - }, - "replace": { - "tightenco/collect": "self.version" + "illuminate/contracts": "5.0.*", + "php": ">=5.4.0" }, "suggest": { - "illuminate/filesystem": "Required to use the composer class (5.2.*).", - "symfony/process": "Required to use the composer class (~3.3).", - "symfony/var-dumper": "Required to use the dd function (~3.3)." + "jeremeamia/superclosure": "Required to be able to serialize closures (~2.0).", + "symfony/var-dumper": "Required to use the dd function (2.6.*)." }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.5-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -266,41 +319,35 @@ "authors": [ { "name": "Taylor Otwell", - "email": "taylor@laravel.com" + "email": "taylorotwell@gmail.com" } ], "description": "The Illuminate Support package.", - "homepage": "https://laravel.com", - "time": "2017-11-10 14:22:23" + "homepage": "http://laravel.com", + "time": "2015-06-04 12:15:51" }, { "name": "nesbot/carbon", - "version": "dev-master", + "version": "1.21.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "926aee5ab38c2868816aa760f862a85ad01cb61a" + "reference": "7b08ec6f75791e130012f206e3f7b0e76e18e3d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/926aee5ab38c2868816aa760f862a85ad01cb61a", - "reference": "926aee5ab38c2868816aa760f862a85ad01cb61a", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/7b08ec6f75791e130012f206e3f7b0e76e18e3d7", + "reference": "7b08ec6f75791e130012f206e3f7b0e76e18e3d7", "shasum": "" }, "require": { "php": ">=5.3.0", - "symfony/translation": "~2.6 || ~3.0" + "symfony/translation": "~2.6|~3.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "~2", - "phpunit/phpunit": "~4.0 || ~5.0" + "phpunit/phpunit": "~4.0|~5.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.23-dev" - } - }, "autoload": { "psr-4": { "Carbon\\": "src/Carbon/" @@ -324,258 +371,47 @@ "datetime", "time" ], - "time": "2017-02-06 22:02:47" - }, - { - "name": "psr/container", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "2cc4a01788191489dc7459446ba832fa79a216a7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/2cc4a01788191489dc7459446ba832fa79a216a7", - "reference": "2cc4a01788191489dc7459446ba832fa79a216a7", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "time": "2017-06-28 15:35:32" - }, - { - "name": "psr/log", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2016-10-10 12:19:37" - }, - { - "name": "psr/simple-cache", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/php-fig/simple-cache.git", - "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", - "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\SimpleCache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interfaces for simple caching", - "keywords": [ - "cache", - "caching", - "psr", - "psr-16", - "simple-cache" - ], - "time": "2017-10-23 01:57:42" + "time": "2015-11-04 20:07:17" }, { "name": "symfony/console", - "version": "3.4.x-dev", + "version": "2.6.x-dev", + "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "0f859c42d6b557fdac74754c9823170765ae3872" + "reference": "0e5e18ae09d3f5c06367759be940e9ed3f568359" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/0f859c42d6b557fdac74754c9823170765ae3872", - "reference": "0f859c42d6b557fdac74754c9823170765ae3872", + "url": "https://api.github.com/repos/symfony/console/zipball/0e5e18ae09d3f5c06367759be940e9ed3f568359", + "reference": "0e5e18ae09d3f5c06367759be940e9ed3f568359", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/debug": "~2.8|~3.0|~4.0", - "symfony/polyfill-mbstring": "~1.0" - }, - "conflict": { - "symfony/dependency-injection": "<3.4", - "symfony/process": "<3.3" + "php": ">=5.3.3" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.3|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/event-dispatcher": "~2.8|~3.0|~4.0", - "symfony/lock": "~3.4|~4.0", - "symfony/process": "~3.3|~4.0" + "symfony/event-dispatcher": "~2.1", + "symfony/phpunit-bridge": "~2.7", + "symfony/process": "~2.1" }, "suggest": { "psr/log": "For using the console logger", "symfony/event-dispatcher": "", - "symfony/lock": "", "symfony/process": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "2.6-dev" } }, "autoload": { - "psr-4": { + "psr-0": { "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" } - ], - "description": "Symfony Console Component", - "homepage": "https://symfony.com", - "time": "2017-11-12 16:53:54" - }, - { - "name": "symfony/debug", - "version": "3.4.x-dev", - "source": { - "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "24b7bbfc7c1aed6540f8d5dc7ff9bb8467ac9e32" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/24b7bbfc7c1aed6540f8d5dc7ff9bb8467ac9e32", - "reference": "24b7bbfc7c1aed6540f8d5dc7ff9bb8467ac9e32", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/http-kernel": "~2.8|~3.0|~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -591,9 +427,9 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Debug Component", + "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-11-11 15:39:06" + "time": "2015-07-26 09:08:40" }, { "name": "symfony/polyfill-mbstring", @@ -601,24 +437,21 @@ "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296" + "reference": "0b6a8940385311a24e060ec1fe35680e17c74497" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0b6a8940385311a24e060ec1fe35680e17c74497", + "reference": "0b6a8940385311a24e060ec1fe35680e17c74497", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "suggest": { - "ext-mbstring": "For best performance" - }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -652,38 +485,34 @@ "portable", "shim" ], - "time": "2017-10-11 12:05:26" + "time": "2015-11-04 20:28:58" }, { "name": "symfony/translation", - "version": "3.4.x-dev", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "34c2376013f9e151b2e7f935a77e42586b28d8c6" + "reference": "7f14717150a7445f8475864d1235875dd04061fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/34c2376013f9e151b2e7f935a77e42586b28d8c6", - "reference": "34c2376013f9e151b2e7f935a77e42586b28d8c6", + "url": "https://api.github.com/repos/symfony/translation/zipball/7f14717150a7445f8475864d1235875dd04061fb", + "reference": "7f14717150a7445f8475864d1235875dd04061fb", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", + "php": ">=5.5.9", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/config": "<2.8", - "symfony/dependency-injection": "<3.4", - "symfony/yaml": "<3.4" + "symfony/config": "<2.8" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/finder": "~2.8|~3.0|~4.0", - "symfony/intl": "^2.8.18|^3.2.5|~4.0", - "symfony/yaml": "~3.4|~4.0" + "symfony/config": "~2.8|~3.0", + "symfony/intl": "~2.8|~3.0", + "symfony/yaml": "~2.8|~3.0" }, "suggest": { "psr/log": "To use logging capability in translator", @@ -693,7 +522,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -720,127 +549,13 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2017-11-07 14:20:24" + "time": "2015-11-18 13:48:51" } ], "packages-dev": [ - { - "name": "blackfire/php-sdk", - "version": "v1.11.0", - "source": { - "type": "git", - "url": "https://github.com/blackfireio/php-sdk.git", - "reference": "a71debd3468c932059e8672b8280342c07eb2c6f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/blackfireio/php-sdk/zipball/a71debd3468c932059e8672b8280342c07eb2c6f", - "reference": "a71debd3468c932059e8672b8280342c07eb2c6f", - "shasum": "" - }, - "require": { - "composer/ca-bundle": "^1.0", - "php": ">=5.2.0" - }, - "suggest": { - "ext-blackfire": "The C version of the Blackfire probe", - "ext-zlib": "To push config to remote profiling targets" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.5.x-dev" - } - }, - "autoload": { - "files": [ - "src/autostart.php" - ], - "psr-4": { - "Blackfire\\": "src/Blackfire" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Blackfire.io", - "email": "support@blackfire.io" - } - ], - "description": "Blackfire.io PHP SDK", - "keywords": [ - "performance", - "profiler", - "uprofiler", - "xhprof" - ], - "time": "2017-09-12T15:54:33+00:00" - }, - { - "name": "composer/ca-bundle", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/composer/ca-bundle.git", - "reference": "36344aeffdc37711335563e6108cda86566432a6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/36344aeffdc37711335563e6108cda86566432a6", - "reference": "36344aeffdc37711335563e6108cda86566432a6", - "shasum": "" - }, - "require": { - "ext-openssl": "*", - "ext-pcre": "*", - "php": "^5.3.2 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.5", - "psr/log": "^1.0", - "symfony/process": "^2.5 || ^3.0" - }, - "suggest": { - "symfony/process": "This is necessary to reliably check whether openssl_x509_parse is vulnerable on older php versions, but can be ignored on PHP 5.5.6+" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\CaBundle\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - } - ], - "description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.", - "keywords": [ - "cabundle", - "cacert", - "certificate", - "ssl", - "tls" - ], - "time": "2017-11-13T15:51:25+00:00" - }, { "name": "doctrine/instantiator", - "version": "1.0.x-dev", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", @@ -890,24 +605,24 @@ "constructor", "instantiate" ], - "time": "2015-06-14T21:17:01+00:00" + "time": "2015-06-14 21:17:01" }, { "name": "hamcrest/hamcrest-php", - "version": "dev-master", + "version": "v1.2.2", "source": { "type": "git", "url": "https://github.com/hamcrest/hamcrest-php.git", - "reference": "10b977bd20ea6a2fcf0e32a941c9140fbdb75033" + "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/10b977bd20ea6a2fcf0e32a941c9140fbdb75033", - "reference": "10b977bd20ea6a2fcf0e32a941c9140fbdb75033", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/b37020aa976fa52d3de9aa904aa2522dc518f79c", + "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c", "shasum": "" }, "require": { - "php": "^5.3|^7.0" + "php": ">=5.3.2" }, "replace": { "cordoval/hamcrest-php": "*", @@ -916,53 +631,49 @@ }, "require-dev": { "phpunit/php-file-iterator": "1.3.3", - "phpunit/phpunit": "~4.0", - "satooshi/php-coveralls": "^1.0" + "satooshi/php-coveralls": "dev-master" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, "autoload": { "classmap": [ "hamcrest" + ], + "files": [ + "hamcrest/Hamcrest.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "BSD" ], "description": "This is the PHP port of Hamcrest Matchers", "keywords": [ "test" ], - "time": "2017-04-07T19:46:20+00:00" + "time": "2015-05-11 14:41:42" }, { "name": "illuminate/container", - "version": "5.5.x-dev", + "version": "5.0.x-dev", "source": { "type": "git", "url": "https://github.com/illuminate/container.git", - "reference": "a7095697649494ced03d33cf4e756ccee94f8ab2" + "reference": "c5a78e53ef15204469b5b072d390af9785a82d32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/container/zipball/a7095697649494ced03d33cf4e756ccee94f8ab2", - "reference": "a7095697649494ced03d33cf4e756ccee94f8ab2", + "url": "https://api.github.com/repos/illuminate/container/zipball/c5a78e53ef15204469b5b072d390af9785a82d32", + "reference": "c5a78e53ef15204469b5b072d390af9785a82d32", "shasum": "" }, "require": { - "illuminate/contracts": "5.5.*", - "php": ">=7.0", - "psr/container": "~1.0" + "illuminate/contracts": "5.0.*", + "php": ">=5.4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.5-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -977,45 +688,44 @@ "authors": [ { "name": "Taylor Otwell", - "email": "taylor@laravel.com" + "email": "taylorotwell@gmail.com" } ], "description": "The Illuminate Container package.", - "homepage": "https://laravel.com", - "time": "2017-08-14T18:00:01+00:00" + "homepage": "http://laravel.com", + "time": "2015-05-29 20:16:27" }, { "name": "illuminate/database", - "version": "5.5.x-dev", + "version": "5.0.x-dev", "source": { "type": "git", "url": "https://github.com/illuminate/database.git", - "reference": "b2417e8fb34b76a066f1576c6d7752470d74a701" + "reference": "e8933b4765aaa1b65f3f4a3638b6a0ea61b76a5a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/database/zipball/b2417e8fb34b76a066f1576c6d7752470d74a701", - "reference": "b2417e8fb34b76a066f1576c6d7752470d74a701", + "url": "https://api.github.com/repos/illuminate/database/zipball/e8933b4765aaa1b65f3f4a3638b6a0ea61b76a5a", + "reference": "e8933b4765aaa1b65f3f4a3638b6a0ea61b76a5a", "shasum": "" }, "require": { - "illuminate/container": "5.5.*", - "illuminate/contracts": "5.5.*", - "illuminate/support": "5.5.*", - "php": ">=7.0" + "illuminate/container": "5.0.*", + "illuminate/contracts": "5.0.*", + "illuminate/support": "5.0.*", + "nesbot/carbon": "~1.0", + "php": ">=5.4.0" }, "suggest": { - "doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.5).", - "fzaninotto/faker": "Required to use the eloquent factory builder (~1.4).", - "illuminate/console": "Required to use the database commands (5.5.*).", - "illuminate/events": "Required to use the observers with Eloquent (5.5.*).", - "illuminate/filesystem": "Required to use the migrations (5.5.*).", - "illuminate/pagination": "Required to paginate the result set (5.5.*)." + "doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.4).", + "illuminate/console": "Required to use the database commands (5.0.*).", + "illuminate/events": "Required to use the observers with Eloquent (5.0.*).", + "illuminate/filesystem": "Required to use the migrations (5.0.*)." }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.5-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -1030,31 +740,31 @@ "authors": [ { "name": "Taylor Otwell", - "email": "taylor@laravel.com" + "email": "taylorotwell@gmail.com" } ], "description": "The Illuminate Database package.", - "homepage": "https://laravel.com", + "homepage": "http://laravel.com", "keywords": [ "database", "laravel", "orm", "sql" ], - "time": "2017-11-09T13:48:37+00:00" + "time": "2015-06-02 13:39:10" }, { "name": "michelf/php-markdown", - "version": "1.7.0", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/michelf/php-markdown.git", - "reference": "1f51cc520948f66cd2af8cbc45a5ee175e774220" + "reference": "e1aabe18173231ebcefc90e615565742fc1c7fd9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/michelf/php-markdown/zipball/1f51cc520948f66cd2af8cbc45a5ee175e774220", - "reference": "1f51cc520948f66cd2af8cbc45a5ee175e774220", + "url": "https://api.github.com/repos/michelf/php-markdown/zipball/e1aabe18173231ebcefc90e615565742fc1c7fd9", + "reference": "e1aabe18173231ebcefc90e615565742fc1c7fd9", "shasum": "" }, "require": { @@ -1076,15 +786,15 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "John Gruber", + "homepage": "http://daringfireball.net/" + }, { "name": "Michel Fortin", "email": "michel.fortin@michelf.ca", "homepage": "https://michelf.ca/", "role": "Developer" - }, - { - "name": "John Gruber", - "homepage": "https://daringfireball.net/" } ], "description": "PHP Markdown", @@ -1092,29 +802,29 @@ "keywords": [ "markdown" ], - "time": "2016-10-29T18:58:20+00:00" + "time": "2015-03-01 12:03:08" }, { "name": "mockery/mockery", "version": "dev-master", "source": { "type": "git", - "url": "https://github.com/mockery/mockery.git", - "reference": "b3749e485d200cb95c5778193b0aa70c2c8e8003" + "url": "https://github.com/padraic/mockery.git", + "reference": "15f6bb72f66df6857b957bedd09dc4fd0ace3b03" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/b3749e485d200cb95c5778193b0aa70c2c8e8003", - "reference": "b3749e485d200cb95c5778193b0aa70c2c8e8003", + "url": "https://api.github.com/repos/padraic/mockery/zipball/15f6bb72f66df6857b957bedd09dc4fd0ace3b03", + "reference": "15f6bb72f66df6857b957bedd09dc4fd0ace3b03", "shasum": "" }, "require": { - "hamcrest/hamcrest-php": "~2.0", + "hamcrest/hamcrest-php": "~1.1", "lib-pcre": ">=7.0", - "php": ">=5.6.0" + "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "~5.7|~6.1" + "phpunit/phpunit": "~4.0" }, "type": "library", "extra": { @@ -1144,7 +854,7 @@ } ], "description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.", - "homepage": "https://github.com/mockery/mockery", + "homepage": "http://github.com/padraic/mockery", "keywords": [ "BDD", "TDD", @@ -1157,42 +867,36 @@ "test double", "testing" ], - "time": "2017-11-09T13:38:08+00:00" + "time": "2015-11-17 13:12:31" }, { "name": "nikic/php-parser", - "version": "3.x-dev", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "94ca9a7ab9a9eff7fa15a4a173a8735755ed30f8" + "reference": "f78af2c9c86107aa1a34cd1dbb5bbe9eeb0d9f51" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/94ca9a7ab9a9eff7fa15a4a173a8735755ed30f8", - "reference": "94ca9a7ab9a9eff7fa15a4a173a8735755ed30f8", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f78af2c9c86107aa1a34cd1dbb5bbe9eeb0d9f51", + "reference": "f78af2c9c86107aa1a34cd1dbb5bbe9eeb0d9f51", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "~4.0|~5.0" + "php": ">=5.3" }, - "bin": [ - "bin/php-parse" - ], "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "1.4-dev" } }, "autoload": { - "psr-4": { - "PhpParser\\": "lib/PhpParser" - } + "files": [ + "lib/bootstrap.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1208,20 +912,20 @@ "parser", "php" ], - "time": "2017-11-13T00:14:55+00:00" + "time": "2015-09-19 14:15:08" }, { "name": "phpdocumentor/reflection-docblock", - "version": "2.0.5", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "e6a969a640b00d8daa3c66518b0405fb41ae0c4b" + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e6a969a640b00d8daa3c66518b0405fb41ae0c4b", - "reference": "e6a969a640b00d8daa3c66518b0405fb41ae0c4b", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", "shasum": "" }, "require": { @@ -1257,7 +961,7 @@ "email": "mike.vanriel@naenius.com" } ], - "time": "2016-01-25T08:17:30+00:00" + "time": "2015-02-03 12:10:50" }, { "name": "phpspec/prophecy", @@ -1265,29 +969,26 @@ "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "ddd9d7ffff1d7c3acd1a79a8e21d5ee5ea7beace" + "reference": "4f9b1eaf0a7da77c362f8d91cbc68ab1f4718d62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/ddd9d7ffff1d7c3acd1a79a8e21d5ee5ea7beace", - "reference": "ddd9d7ffff1d7c3acd1a79a8e21d5ee5ea7beace", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4f9b1eaf0a7da77c362f8d91cbc68ab1f4718d62", + "reference": "4f9b1eaf0a7da77c362f8d91cbc68ab1f4718d62", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" + "phpdocumentor/reflection-docblock": "~2.0", + "sebastian/comparator": "~1.1" }, "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7" + "phpspec/phpspec": "~2.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7.x-dev" + "dev-master": "1.5.x-dev" } }, "autoload": { @@ -1320,7 +1021,7 @@ "spy", "stub" ], - "time": "2017-11-07T12:00:44+00:00" + "time": "2015-09-22 14:49:23" }, { "name": "phpunit/php-code-coverage", @@ -1382,20 +1083,20 @@ "testing", "xunit" ], - "time": "2015-10-06T15:47:00+00:00" + "time": "2015-10-06 15:47:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.x-dev", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "63304292f3cf89b2382b90dd7a2abf9e0ba232f9" + "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/63304292f3cf89b2382b90dd7a2abf9e0ba232f9", - "reference": "63304292f3cf89b2382b90dd7a2abf9e0ba232f9", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", + "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", "shasum": "" }, "require": { @@ -1429,7 +1130,7 @@ "filesystem", "iterator" ], - "time": "2017-10-30T04:21:02+00:00" + "time": "2015-06-21 13:08:43" }, { "name": "phpunit/php-text-template", @@ -1470,7 +1171,7 @@ "keywords": [ "template" ], - "time": "2015-06-21T13:50:34+00:00" + "time": "2015-06-21 13:50:34" }, { "name": "phpunit/php-timer", @@ -1478,26 +1179,18 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "d107f347d368dd8a384601398280c7c608390ab7" + "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/d107f347d368dd8a384601398280c7c608390ab7", - "reference": "d107f347d368dd8a384601398280c7c608390ab7", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b", + "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "php": ">=5.3.3" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, "autoload": { "classmap": [ "src/" @@ -1519,20 +1212,20 @@ "keywords": [ "timer" ], - "time": "2017-03-07T15:42:04+00:00" + "time": "2015-06-21 08:01:12" }, { "name": "phpunit/php-token-stream", - "version": "1.4.x-dev", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "958103f327daef5dd0bb328dec53e0a9e43cfaf7" + "reference": "cab6c6fefee93d7b7c3a01292a0fe0884ea66644" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/958103f327daef5dd0bb328dec53e0a9e43cfaf7", - "reference": "958103f327daef5dd0bb328dec53e0a9e43cfaf7", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/cab6c6fefee93d7b7c3a01292a0fe0884ea66644", + "reference": "cab6c6fefee93d7b7c3a01292a0fe0884ea66644", "shasum": "" }, "require": { @@ -1568,7 +1261,7 @@ "keywords": [ "tokenizer" ], - "time": "2017-03-07T08:21:50+00:00" + "time": "2015-09-23 14:46:55" }, { "name": "phpunit/phpunit", @@ -1576,12 +1269,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "18e5f52e8412d23e739f7d8744e177039860e800" + "reference": "d82e69c1b34337eae1628c5e2e3b01d2082c4aa9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/18e5f52e8412d23e739f7d8744e177039860e800", - "reference": "18e5f52e8412d23e739f7d8744e177039860e800", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d82e69c1b34337eae1628c5e2e3b01d2082c4aa9", + "reference": "d82e69c1b34337eae1628c5e2e3b01d2082c4aa9", "shasum": "" }, "require": { @@ -1595,9 +1288,9 @@ "phpunit/php-code-coverage": "~2.1", "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "^1.0.6", + "phpunit/php-timer": ">=1.0.6", "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.2.2", + "sebastian/comparator": "~1.1", "sebastian/diff": "~1.2", "sebastian/environment": "~1.3", "sebastian/exporter": "~1.2", @@ -1640,7 +1333,7 @@ "testing", "xunit" ], - "time": "2017-06-23T12:44:27+00:00" + "time": "2015-11-17 20:03:40" }, { "name": "phpunit/phpunit-mock-objects", @@ -1696,7 +1389,7 @@ "mock", "xunit" ], - "time": "2015-10-02T06:51:40+00:00" + "time": "2015-10-02 06:51:40" }, { "name": "pimple/pimple", @@ -1704,25 +1397,21 @@ "source": { "type": "git", "url": "https://github.com/silexphp/Pimple.git", - "reference": "b5e5c1809fc323428715aa6a66ddca180e0adc0f" + "reference": "64e0f8320639b434baa073a40dd1e037e3286555" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/silexphp/Pimple/zipball/b5e5c1809fc323428715aa6a66ddca180e0adc0f", - "reference": "b5e5c1809fc323428715aa6a66ddca180e0adc0f", + "url": "https://api.github.com/repos/silexphp/Pimple/zipball/64e0f8320639b434baa073a40dd1e037e3286555", + "reference": "64e0f8320639b434baa073a40dd1e037e3286555", "shasum": "" }, "require": { - "php": ">=5.3.0", - "psr/container": "^1.0" - }, - "require-dev": { - "symfony/phpunit-bridge": "^3.2" + "php": ">=5.3.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -1746,7 +1435,7 @@ "container", "dependency injection" ], - "time": "2017-08-23T11:42:00+00:00" + "time": "2015-09-11 15:11:22" }, { "name": "sami/sami", @@ -1754,30 +1443,26 @@ "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/Sami.git", - "reference": "2a158d9ddf02f510257fff7718b00ffed9b65a34" + "reference": "0a526ff0d6e098f6dd07d2e131cb1487cbace112" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/Sami/zipball/2a158d9ddf02f510257fff7718b00ffed9b65a34", - "reference": "2a158d9ddf02f510257fff7718b00ffed9b65a34", + "url": "https://api.github.com/repos/FriendsOfPHP/Sami/zipball/0a526ff0d6e098f6dd07d2e131cb1487cbace112", + "reference": "0a526ff0d6e098f6dd07d2e131cb1487cbace112", "shasum": "" }, "require": { - "blackfire/php-sdk": "^1.5.18", "michelf/php-markdown": "~1.3", - "nikic/php-parser": "~3.0", - "php": ">=7.0", + "nikic/php-parser": "~1.0", + "php": ">=5.3.9", "phpdocumentor/reflection-docblock": "~2.0", "pimple/pimple": "~3.0", - "symfony/console": "~3.0", - "symfony/filesystem": "~3.0", - "symfony/finder": "~3.0", - "symfony/process": "~3.0", - "symfony/yaml": "~3.0", - "twig/twig": "~2.0" - }, - "require-dev": { - "symfony/phpunit-bridge": "~3.2" + "symfony/console": "~2.1", + "symfony/filesystem": "~2.1", + "symfony/finder": "~2.1", + "symfony/process": "~2.1", + "symfony/yaml": "~2.1", + "twig/twig": "~1.20|~2.0" }, "bin": [ "sami.php" @@ -1785,7 +1470,7 @@ "type": "application", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1808,26 +1493,26 @@ "keywords": [ "phpdoc" ], - "time": "2017-09-06T14:17:25+00:00" + "time": "2015-10-07 15:32:20" }, { "name": "sebastian/comparator", - "version": "1.2.x-dev", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "18a5d97c25f408f48acaf6d1b9f4079314c5996a" + "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/18a5d97c25f408f48acaf6d1b9f4079314c5996a", - "reference": "18a5d97c25f408f48acaf6d1b9f4079314c5996a", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", + "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", "shasum": "" }, "require": { "php": ">=5.3.3", "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" + "sebastian/exporter": "~1.2" }, "require-dev": { "phpunit/phpunit": "~4.4" @@ -1872,32 +1557,32 @@ "compare", "equality" ], - "time": "2017-03-07T10:34:43+00:00" + "time": "2015-07-26 15:48:44" }, { "name": "sebastian/diff", - "version": "1.4.x-dev", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" + "reference": "6899b3e33bfbd386d88b5eea5f65f563e8793051" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/6899b3e33bfbd386d88b5eea5f65f563e8793051", + "reference": "6899b3e33bfbd386d88b5eea5f65f563e8793051", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "~4.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "1.3-dev" } }, "autoload": { @@ -1920,31 +1605,31 @@ } ], "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", + "homepage": "http://www.github.com/sebastianbergmann/diff", "keywords": [ "diff" ], - "time": "2017-05-22T07:24:03+00:00" + "time": "2015-06-22 14:15:55" }, { "name": "sebastian/environment", - "version": "1.3.x-dev", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "67f55699c2810ff0f2cc47478bbdeda8567e68ee" + "reference": "6324c907ce7a52478eeeaede764f48733ef5ae44" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/67f55699c2810ff0f2cc47478bbdeda8567e68ee", - "reference": "67f55699c2810ff0f2cc47478bbdeda8567e68ee", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6324c907ce7a52478eeeaede764f48733ef5ae44", + "reference": "6324c907ce7a52478eeeaede764f48733ef5ae44", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "~4.4" }, "type": "library", "extra": { @@ -1974,34 +1659,34 @@ "environment", "hhvm" ], - "time": "2017-02-28T08:18:59+00:00" + "time": "2015-08-03 06:14:51" }, { "name": "sebastian/exporter", - "version": "1.2.x-dev", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "dcd43bcc0fd3551bd2ede0081882d549bb78225d" + "reference": "f88f8936517d54ae6d589166810877fb2015d0a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/dcd43bcc0fd3551bd2ede0081882d549bb78225d", - "reference": "dcd43bcc0fd3551bd2ede0081882d549bb78225d", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/f88f8936517d54ae6d589166810877fb2015d0a2", + "reference": "f88f8936517d54ae6d589166810877fb2015d0a2", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0", - "sebastian/recursion-context": "^1.0" + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "~4.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { @@ -2041,27 +1726,27 @@ "export", "exporter" ], - "time": "2017-02-26T13:09:30+00:00" + "time": "2015-08-09 04:23:41" }, { "name": "sebastian/global-state", - "version": "1.1.x-dev", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "cea85a84b00f2795341ebbbca4fa396347f2494e" + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/cea85a84b00f2795341ebbbca4fa396347f2494e", - "reference": "cea85a84b00f2795341ebbbca4fa396347f2494e", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "~4.2|~5.0" + "phpunit/phpunit": "~4.2" }, "suggest": { "ext-uopz": "*" @@ -2092,20 +1777,20 @@ "keywords": [ "global state" ], - "time": "2017-02-23T14:11:06+00:00" + "time": "2015-10-12 03:26:01" }, { "name": "sebastian/recursion-context", - "version": "1.0.x-dev", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7" + "reference": "994d4a811bafe801fb06dccbee797863ba2792ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b19cc3298482a335a95f3016d2f8a6950f0fbcd7", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/994d4a811bafe801fb06dccbee797863ba2792ba", + "reference": "994d4a811bafe801fb06dccbee797863ba2792ba", "shasum": "" }, "require": { @@ -2145,7 +1830,7 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-10-03T07:41:43+00:00" + "time": "2015-06-21 08:04:50" }, { "name": "sebastian/version", @@ -2180,29 +1865,29 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21T13:59:46+00:00" + "time": "2015-06-21 13:59:46" }, { "name": "symfony/filesystem", - "version": "3.4.x-dev", + "version": "2.8.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "4e75c6190f3cc5243dfe227a843aa305dec976e7" + "reference": "8caf603ed1551f4408195557af56c1a68aec36b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/4e75c6190f3cc5243dfe227a843aa305dec976e7", - "reference": "4e75c6190f3cc5243dfe227a843aa305dec976e7", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/8caf603ed1551f4408195557af56c1a68aec36b3", + "reference": "8caf603ed1551f4408195557af56c1a68aec36b3", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": ">=5.3.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "2.8-dev" } }, "autoload": { @@ -2229,29 +1914,29 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2017-11-12T20:37:29+00:00" + "time": "2015-11-18 13:45:00" }, { "name": "symfony/finder", - "version": "3.4.x-dev", + "version": "2.8.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "dac8d7db537bac7ad8143eb11360a8c2231f251a" + "reference": "ead9b07af4ba77b6507bee697396a5c79e633f08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/dac8d7db537bac7ad8143eb11360a8c2231f251a", - "reference": "dac8d7db537bac7ad8143eb11360a8c2231f251a", + "url": "https://api.github.com/repos/symfony/finder/zipball/ead9b07af4ba77b6507bee697396a5c79e633f08", + "reference": "ead9b07af4ba77b6507bee697396a5c79e633f08", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": ">=5.3.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "2.8-dev" } }, "autoload": { @@ -2278,29 +1963,29 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2017-11-05T16:10:10+00:00" + "time": "2015-10-30 20:15:42" }, { "name": "symfony/process", - "version": "3.4.x-dev", + "version": "2.8.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "c1638ca1865a54e036ec78d209a72660a5d8ec8b" + "reference": "8ad2cbb13f20580a01d6451d20ce46c7890fb183" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/c1638ca1865a54e036ec78d209a72660a5d8ec8b", - "reference": "c1638ca1865a54e036ec78d209a72660a5d8ec8b", + "url": "https://api.github.com/repos/symfony/process/zipball/8ad2cbb13f20580a01d6451d20ce46c7890fb183", + "reference": "8ad2cbb13f20580a01d6451d20ce46c7890fb183", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": ">=5.3.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "2.8-dev" } }, "autoload": { @@ -2327,38 +2012,29 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2017-11-13T18:20:08+00:00" + "time": "2015-11-19 16:12:55" }, { "name": "symfony/yaml", - "version": "3.4.x-dev", + "version": "2.8.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "14568820af0af65e8ae97c3999b58cc94ea408bf" + "reference": "f65177d7093bc29aefebfbdbe496b9e3a6292653" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/14568820af0af65e8ae97c3999b58cc94ea408bf", - "reference": "14568820af0af65e8ae97c3999b58cc94ea408bf", + "url": "https://api.github.com/repos/symfony/yaml/zipball/f65177d7093bc29aefebfbdbe496b9e3a6292653", + "reference": "f65177d7093bc29aefebfbdbe496b9e3a6292653", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" - }, - "conflict": { - "symfony/console": "<3.4" - }, - "require-dev": { - "symfony/console": "~3.4|~4.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" + "php": ">=5.3.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "2.8-dev" } }, "autoload": { @@ -2385,43 +2061,39 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-11-10T19:03:56+00:00" + "time": "2015-11-18 13:45:00" }, { "name": "twig/twig", - "version": "2.x-dev", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "0b9a64d842bf7f15c9f3964909100a6663e97db2" + "reference": "5cdca6bc1f1510c365c169dda68c5e1ebbad1d93" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/0b9a64d842bf7f15c9f3964909100a6663e97db2", - "reference": "0b9a64d842bf7f15c9f3964909100a6663e97db2", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/5cdca6bc1f1510c365c169dda68c5e1ebbad1d93", + "reference": "5cdca6bc1f1510c365c169dda68c5e1ebbad1d93", "shasum": "" }, "require": { - "php": "^7.0", + "php": ">=5.5", "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { - "psr/container": "^1.0", "symfony/debug": "~2.7", - "symfony/phpunit-bridge": "~3.3@dev" + "symfony/phpunit-bridge": "~2.7" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.0-dev" } }, "autoload": { "psr-0": { "Twig_": "lib/" - }, - "psr-4": { - "Twig\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -2451,7 +2123,7 @@ "keywords": [ "templating" ], - "time": "2017-11-12T18:48:08+00:00" + "time": "2015-10-29 23:23:02" } ], "aliases": [], @@ -2463,7 +2135,8 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.5.0" + "php": ">=5.4.0" }, "platform-dev": [] } + diff --git a/src/Entrust/Contracts/EntrustUserInterface.php b/src/Entrust/Contracts/EntrustUserInterface.php index 184eace9..f46804b0 100644 --- a/src/Entrust/Contracts/EntrustUserInterface.php +++ b/src/Entrust/Contracts/EntrustUserInterface.php @@ -77,4 +77,32 @@ public function attachRoles($roles); * @param mixed $roles */ public function detachRoles($roles); + + /** + * Alias to eloquent many-to-many relation's attach() method. + * + * @param mixed $permission + */ + public function attachPermission($permission); + + /** + * Alias to eloquent many-to-many relation's detach() method. + * + * @param mixed $permission + */ + public function detachPermission($permission); + + /** + * Attach multiple perms to a user + * + * @param mixed $permissions + */ + public function attachPermissions(array $permissions); + + /** + * Detach multiple perms to a user + * + * @param mixed $permissions + */ + public function detachPermissions($permissions=null); } diff --git a/src/Entrust/Traits/EntrustPermissionTrait.php b/src/Entrust/Traits/EntrustPermissionTrait.php index d2a460f6..254efc62 100644 --- a/src/Entrust/Traits/EntrustPermissionTrait.php +++ b/src/Entrust/Traits/EntrustPermissionTrait.php @@ -19,7 +19,17 @@ trait EntrustPermissionTrait */ public function roles() { - return $this->belongsToMany(Config::get('entrust.role'), Config::get('entrust.permission_role_table'), Config::get('entrust.permission_foreign_key'), Config::get('entrust.role_foreign_key')); + return $this->belongsToMany(Config::get('entrust.role'), Config::get('entrust.permission_role_table')); + } + + /** + * Many-to-Many relations with permission model. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function users() + { + return $this->belongsToMany(Config::get('entrust.permission'),Config::get('entrust.user_permission_table'), 'user_id','permission_id'); } /** @@ -36,6 +46,7 @@ public static function boot() static::deleting(function($permission) { if (!method_exists(Config::get('entrust.permission'), 'bootSoftDeletes')) { $permission->roles()->sync([]); + $permission->users()->sync([]); } return true; diff --git a/src/Entrust/Traits/EntrustUserTrait.php b/src/Entrust/Traits/EntrustUserTrait.php index c799bbeb..e5e828d5 100644 --- a/src/Entrust/Traits/EntrustUserTrait.php +++ b/src/Entrust/Traits/EntrustUserTrait.php @@ -32,6 +32,18 @@ public function cachedRoles() else return $this->roles()->get(); } + public function cachedPerms() + { + $userPrimaryKey = $this->primaryKey; + $cacheKey = 'entrust_perms_for_user_'.$this->$userPrimaryKey; + if(Cache::getStore() instanceof TaggableStore) { + return Cache::tags(Config::get('entrust.user_permission_table'))->remember($cacheKey, Config::get('cache.ttl'), function () { + return $this->perms()->get(); + }); + } + else return $this->perms()->get(); + } + /** * {@inheritDoc} */ @@ -40,6 +52,9 @@ public function save(array $options = []) if(Cache::getStore() instanceof TaggableStore) { Cache::tags(Config::get('entrust.role_user_table'))->flush(); } + if (Cache::getStore() instanceof TaggableStore){ + Cache::tags(Config::get('entrust.user_permission_table'))->flush(); + } return parent::save($options); } @@ -52,6 +67,9 @@ public function delete(array $options = []) if(Cache::getStore() instanceof TaggableStore) { Cache::tags(Config::get('entrust.role_user_table'))->flush(); } + if(Cache::getStore() instanceof TaggableStore) { + Cache::tags(Config::get('entrust.user_permission_table'))->flush(); + } return $result; } @@ -64,6 +82,9 @@ public function restore() if(Cache::getStore() instanceof TaggableStore) { Cache::tags(Config::get('entrust.role_user_table'))->flush(); } + if (Cache::getStore() instanceof TaggableStore){ + Cache::tags(Config::get('entrust.user_permission_table'))->flush(); + } return $result; } @@ -77,6 +98,16 @@ public function roles() return $this->belongsToMany(Config::get('entrust.role'), Config::get('entrust.role_user_table'), Config::get('entrust.user_foreign_key'), Config::get('entrust.role_foreign_key')); } + /** + * Many-to-Many relations with Permission. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function perms() + { + return $this->belongsToMany(Config::get('entrust.permission'), Config::get('entrust.user_permission_table'), 'user_id', 'permission_id'); + } + /** * Boot the user model * Attach event listener to remove the many-to-many records when trying to delete @@ -91,6 +122,7 @@ public static function boot() static::deleting(function($user) { if (!method_exists(Config::get('auth.providers.users.model'), 'bootSoftDeletes')) { $user->roles()->sync([]); + $user->perms()->sync([]); } return true; @@ -133,6 +165,19 @@ public function hasRole($name, $requireAll = false) return false; } + /** + * Checks if the user has a permission by its name. + * + * @param string|array $name Permission name or array of permission names. + * @param bool $requireAll All permissions in the array are required. + * + * @return bool + */ + public function hasPermission($permission,$requireAll=false) + { + return $this->can($permission,$requireAll); + } + /** * Check if user has a permission by its name. * @@ -167,6 +212,11 @@ public function can($permission, $requireAll = false) } } } + foreach ($this->cachedPerms() as $perm) { + if (str_is($permission,$perm->name)) { + return true; + } + } } return false; @@ -318,4 +368,77 @@ public function scopeWithRole($query, $role) }); } + /** + * Alias to eloquent many-to-many relation's attach() method. + * + * @param mixed $permission + */ + public function attachPermission($permission) + { + if(is_object($permission)) { + $permission = $permission->getKey(); + } + + if(is_array($permission)) { + $permission = $permission['id']; + } + + $this->perms()->attach($permission); + } + /** + * Alias to eloquent many-to-many relation's detach() method. + * + * @param mixed $permission + */ + public function detachPermission($permission) + { + if(is_object($permission)) { + $permission = $permission->getKey(); + } + + if(is_array($permission)) { + $permission = $permission['id']; + } + + $this->perms()->detach($permission); + } + /** + * Attach multiple perms to a user + * + * @param mixed $permissions + */ + public function attachPermissions(array $permissions) + { + foreach ($permissions as $permission) { + $this->attachPermission($permission); + } + } + /** + * Detach multiple perms to a user + * + * @param mixed $permissions + */ + public function detachPermissions($permissions=null) + { + if (!$permissions) $permissions = $this->perms()->get(); + + foreach ($permissions as $permission) { + $this->detachPermission($permission); + } + } + + /** + * Filtering users according to their permission + * + * @param string $permission + * @return users collection + */ + public function scopeWithPermission($query, $permission) + { + return $query->whereHas('permissions', function ($query) use ($permission) + { + $query->where('name', $permission); + }); + } + } diff --git a/src/commands/MigrationCommand.php b/src/commands/MigrationCommand.php index 6310ca35..29a186be 100644 --- a/src/commands/MigrationCommand.php +++ b/src/commands/MigrationCommand.php @@ -50,11 +50,12 @@ public function handle() $roleUserTable = Config::get('entrust.role_user_table'); $permissionsTable = Config::get('entrust.permissions_table'); $permissionRoleTable = Config::get('entrust.permission_role_table'); + $userPermissionTable = Config::get('entrust.user_permission_table'); $this->line(''); $this->info( "Tables: $rolesTable, $roleUserTable, $permissionsTable, $permissionRoleTable" ); - $message = "A migration that creates '$rolesTable', '$roleUserTable', '$permissionsTable', '$permissionRoleTable'". + $message = "A migration that creates '$rolesTable', '$roleUserTable', '$permissionsTable', '$permissionRoleTable', '$userPermissionTable'". " tables will be created in database/migrations directory"; $this->comment($message); @@ -65,7 +66,7 @@ public function handle() $this->line(''); $this->info("Creating migration..."); - if ($this->createMigration($rolesTable, $roleUserTable, $permissionsTable, $permissionRoleTable)) { + if ($this->createMigration($rolesTable, $roleUserTable, $permissionsTable, $permissionRoleTable, $userPermissionTable)) { $this->info("Migration successfully created!"); } else { @@ -87,7 +88,7 @@ public function handle() * * @return bool */ - protected function createMigration($rolesTable, $roleUserTable, $permissionsTable, $permissionRoleTable) + protected function createMigration($rolesTable, $roleUserTable, $permissionsTable, $permissionRoleTable, $userPermissionTable) { $migrationFile = base_path("/database/migrations")."/".date('Y_m_d_His')."_entrust_setup_tables.php"; @@ -96,7 +97,7 @@ protected function createMigration($rolesTable, $roleUserTable, $permissionsTabl $usersTable = $userModel->getTable(); $userKeyName = $userModel->getKeyName(); - $data = compact('rolesTable', 'roleUserTable', 'permissionsTable', 'permissionRoleTable', 'usersTable', 'userKeyName'); + $data = compact('rolesTable', 'roleUserTable', 'permissionsTable', 'permissionRoleTable', 'usersTable', 'userKeyName', 'userPermissionTable'); $output = $this->laravel->view->make('entrust::generators.migration')->with($data)->render(); diff --git a/src/config/config.php b/src/config/config.php index 07da1773..728b7f15 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -129,4 +129,15 @@ | */ 'permission_foreign_key' => 'permission_id', + + /* + |-------------------------------------------------------------------------- + | Entrust user_permission Table + |-------------------------------------------------------------------------- + | + | This is the user_permission table used by Entrust to save assigned + | permissions to the database. + | + */ + 'user_permission_table'=>'user_permission' ]; diff --git a/src/views/generators/migration.blade.php b/src/views/generators/migration.blade.php index 89e8cabd..693070c3 100644 --- a/src/views/generators/migration.blade.php +++ b/src/views/generators/migration.blade.php @@ -58,6 +58,19 @@ public function up() $table->primary(['permission_id', 'role_id']); }); + // Create table for associating permissions to users (Many-to-Many) + Schema::create('{{ $userPermissionTable }}', function (Blueprint $table) { + $table->integer('user_id')->unsigned(); + $table->integer('permission_id')->unsigned(); + + $table->foreign('user_id')->references('id')->on('{{ $usersTable }}') + ->onUpdate('cascade')->onDelete('cascade'); + $table->foreign('permission_id')->references('id')->on('{{ $permissionsTable }}') + ->onUpdate('cascade')->onDelete('cascade'); + + $table->primary(['user_id', 'permission_id']); + }); + DB::commit(); } @@ -72,5 +85,6 @@ public function down() Schema::drop('{{ $permissionsTable }}'); Schema::drop('{{ $roleUserTable }}'); Schema::drop('{{ $rolesTable }}'); + Schema::drop('{{ $userPermissionTable }}'); } } diff --git a/tests/EntrustUserTest.php b/tests/EntrustUserTest.php index 8ea135b5..354e7d4d 100644 --- a/tests/EntrustUserTest.php +++ b/tests/EntrustUserTest.php @@ -33,6 +33,78 @@ public function tearDown() { m::close(); } + public function testPermissions(){ + /* + |------------------------------------------------------------ + | Set + |------------------------------------------------------------ + */ + $belongsToMany = new stdClass(); + $user = m::mock('HasPermissionUser')->makePartial(); + + /* + |------------------------------------------------------------ + | Expectation + |------------------------------------------------------------ + */ + $user->shouldReceive('belongsToMany') + ->with('permission_table_name', 'assigned_permissions_table_name','user_id','permission_id') + ->andReturn($belongsToMany) + ->once(); + + Config::shouldReceive('get')->once()->with('entrust.permission') + ->andReturn('permission_table_name'); + Config::shouldReceive('get')->once()->with('entrust.user_permission_table') + ->andReturn('assigned_permissions_table_name'); + + /* + |------------------------------------------------------------ + | Assertion + |------------------------------------------------------------ + */ + $this->assertSame($belongsToMany, $user->perms()); + } + + public function testHasPermission() + { + /* + |------------------------------------------------------------ + | Set + |------------------------------------------------------------ + */ + $permA=$this->mockPermission('manage_a'); + $permB=$this->mockPermission('manage_b'); + + $user = new HasRoleAndPermissionUser(); + $user->roles=[]; + $user->perms = [$permA, $permB]; + + /* + |------------------------------------------------------------ + | Expectation + |------------------------------------------------------------ + */ + Config::shouldReceive('get')->with('entrust.role_user_table')->andReturn('role_user'); + Config::shouldReceive('get')->with('entrust.user_permission_table')->andReturn('user_permission'); + Config::shouldReceive('get')->with('cache.ttl')->andReturn('1440'); + Cache::shouldReceive('tags->remember')->andReturnUsing($this->setTagsRememberReturnUsing($user)); + Cache::shouldReceive('getStore')->andReturn(new ArrayStore); + + + + /* + |------------------------------------------------------------ + | Assertion + |------------------------------------------------------------ + */ + $this->assertTrue($user->hasPermission('manage_a')); + $this->assertTrue($user->hasPermission('manage_b')); + $this->assertFalse($user->hasPermission('manage_c')); + + $this->assertTrue($user->hasPermission(['manage_a', 'manage_b'])); + $this->assertTrue($user->hasPermission(['manage_a', 'manage_c'])); + $this->assertFalse($user->hasPermission(['manage_a', 'manage_c'], true)); + } public function testRoles() { @@ -119,6 +191,8 @@ public function testCan() $permA = $this->mockPermission('manage_a'); $permB = $this->mockPermission('manage_b'); $permC = $this->mockPermission('manage_c'); + $permD = $this->mockPermission('manage_d'); + $permE = $this->mockPermission('manage_e'); $roleA = $this->mockRole('RoleA'); $roleB = $this->mockRole('RoleB'); @@ -126,20 +200,23 @@ public function testCan() $roleA->perms = [$permA]; $roleB->perms = [$permB, $permC]; - $user = new HasRoleUser(); + $user = new HasRoleAndPermissionUser(); $user->roles = [$roleA, $roleB]; + $user->perms=[$permD,$permE]; /* |------------------------------------------------------------ | Expectation |------------------------------------------------------------ */ - $roleA->shouldReceive('cachedPermissions')->times(11)->andReturn($roleA->perms); - $roleB->shouldReceive('cachedPermissions')->times(7)->andReturn($roleB->perms); - Config::shouldReceive('get')->with('entrust.role_user_table')->times(11)->andReturn('role_user'); - Config::shouldReceive('get')->with('cache.ttl')->times(11)->andReturn('1440'); - Cache::shouldReceive('tags->remember')->times(11)->andReturn($user->roles); - Cache::shouldReceive('getStore')->times(11)->andReturn(new ArrayStore); + $roleA->shouldReceive('cachedPermissions')->andReturn($roleA->perms); + $roleB->shouldReceive('cachedPermissions')->andReturn($roleB->perms); + + Config::shouldReceive('get')->with('entrust.role_user_table')->andReturn('role_user'); + Config::shouldReceive('get')->with('entrust.user_permission_table')->andReturn('user_permission'); + Config::shouldReceive('get')->with('cache.ttl')->andReturn('1440'); + Cache::shouldReceive('tags->remember')->andReturnUsing($this->setTagsRememberReturnUsing($user)); + Cache::shouldReceive('getStore')->andReturn(new ArrayStore); /* |------------------------------------------------------------ @@ -149,12 +226,15 @@ public function testCan() $this->assertTrue($user->can('manage_a')); $this->assertTrue($user->can('manage_b')); $this->assertTrue($user->can('manage_c')); - $this->assertFalse($user->can('manage_d')); + $this->assertTrue($user->can('manage_d')); + $this->assertTrue($user->can('manage_e')); + $this->assertFalse($user->can('manage_f')); $this->assertTrue($user->can(['manage_a', 'manage_b', 'manage_c'])); $this->assertTrue($user->can(['manage_a', 'manage_b', 'manage_d'])); - $this->assertFalse($user->can(['manage_a', 'manage_b', 'manage_d'], true)); - $this->assertFalse($user->can(['manage_d', 'manage_e'])); + $this->assertTrue($user->can(['manage_a', 'manage_b', 'manage_d'], true)); + $this->assertTrue($user->can(['manage_d', 'manage_e'])); + $this->assertFalse($user->can(['manage_a', 'manage_b', 'manage_f'], true)); } @@ -168,24 +248,28 @@ public function testCanWithPlaceholderSupport () $permA = $this->mockPermission('admin.posts'); $permB = $this->mockPermission('admin.pages'); $permC = $this->mockPermission('admin.users'); + $permD = $this->mockPermission('admin.articles'); + $permE = $this->mockPermission('admin.works'); $role = $this->mockRole('Role'); $role->perms = [$permA, $permB, $permC]; - $user = new HasRoleUser(); + $user = new HasRoleAndPermissionUser(); $user->roles = [$role]; + $user->perms=[$permD,$permE]; /* |------------------------------------------------------------ | Expectation |------------------------------------------------------------ */ - $role->shouldReceive('cachedPermissions')->times(6)->andReturn($role->perms); - Config::shouldReceive('get')->with('entrust.role_user_table')->times(6)->andReturn('role_user'); - Config::shouldReceive('get')->with('cache.ttl')->times(6)->andReturn('1440'); - Cache::shouldReceive('tags->remember')->times(6)->andReturn($user->roles); - Cache::shouldReceive('getStore')->times(6)->andReturn(new ArrayStore); + $role->shouldReceive('cachedPermissions')->andReturn($role->perms); + Config::shouldReceive('get')->with('entrust.role_user_table')->andReturn('role_user'); + Config::shouldReceive('get')->with('entrust.user_permission_table')->andReturn('user_permission'); + Config::shouldReceive('get')->with('cache.ttl')->andReturn('1440'); + Cache::shouldReceive('tags->remember')->andReturnUsing($this->setTagsRememberReturnUsing($user)); + Cache::shouldReceive('getStore')->andReturn(new ArrayStore); /* |------------------------------------------------------------ @@ -201,6 +285,17 @@ public function testCanWithPlaceholderSupport () $this->assertFalse($user->can(['site.*'])); } + private function setTagsRememberReturnUsing($user){ + return function ($key,$function)use($user){ + if ($key==="entrust_roles_for_user_{$user->id}"){ + return $user->roles; + }else if ($key==="entrust_perms_for_user_{$user->id}"){ + return $user->perms; + }else{ + return []; + } + }; + } public function testAbilityShouldReturnBoolean() { @@ -212,6 +307,8 @@ public function testAbilityShouldReturnBoolean() $userPermNameA = 'user_can_a'; $userPermNameB = 'user_can_b'; $userPermNameC = 'user_can_c'; + $userPermNameD = 'user_can_d'; + $userPermNameE = 'user_can_e'; $nonUserPermNameA = 'user_cannot_a'; $nonUserPermNameB = 'user_cannot_b'; $userRoleNameA = 'UserRoleA'; @@ -222,6 +319,8 @@ public function testAbilityShouldReturnBoolean() $permA = $this->mockPermission($userPermNameA); $permB = $this->mockPermission($userPermNameB); $permC = $this->mockPermission($userPermNameC); + $permD = $this->mockPermission($userPermNameD); + $permE = $this->mockPermission($userPermNameE); $roleA = $this->mockRole($userRoleNameA); $roleB = $this->mockRole($userRoleNameB); @@ -229,8 +328,9 @@ public function testAbilityShouldReturnBoolean() $roleA->perms = [$permA]; $roleB->perms = [$permB, $permC]; - $user = m::mock('HasRoleUser')->makePartial(); + $user = m::mock('HasRoleAndPermissionUser')->makePartial(); $user->roles = [$roleA, $roleB]; + $user->perms= [$permD,$permE]; $user->id = 4; $user->primaryKey = 'id'; @@ -239,12 +339,13 @@ public function testAbilityShouldReturnBoolean() | Expectation |------------------------------------------------------------ */ - $roleA->shouldReceive('cachedPermissions')->times(16)->andReturn($roleA->perms); - $roleB->shouldReceive('cachedPermissions')->times(12)->andReturn($roleB->perms); - Config::shouldReceive('get')->with('entrust.role_user_table')->times(32)->andReturn('role_user'); - Config::shouldReceive('get')->with('cache.ttl')->times(32)->andReturn('1440'); - Cache::shouldReceive('tags->remember')->times(32)->andReturn($user->roles); - Cache::shouldReceive('getStore')->times(32)->andReturn(new ArrayStore); + $roleA->shouldReceive('cachedPermissions')->andReturn($roleA->perms); + $roleB->shouldReceive('cachedPermissions')->andReturn($roleB->perms); + Config::shouldReceive('get')->with('entrust.role_user_table')->andReturn('role_user'); + Config::shouldReceive('get')->with('entrust.user_permission_table')->andReturn('user_permission'); + Config::shouldReceive('get')->with('cache.ttl')->andReturn('1440'); + Cache::shouldReceive('tags->remember')->andReturnUsing($this->setTagsRememberReturnUsing($user)); + Cache::shouldReceive('getStore')->andReturn(new ArrayStore); $user->shouldReceive('hasRole') ->with(m::anyOf($userRoleNameA, $userRoleNameB), m::anyOf(true, false)) @@ -335,6 +436,8 @@ public function testAbilityShouldReturnArray() $userPermNameA = 'user_can_a'; $userPermNameB = 'user_can_b'; $userPermNameC = 'user_can_c'; + $userPermNameD = 'user_can_d'; + $userPermNameE = 'user_can_e'; $nonUserPermNameA = 'user_cannot_a'; $nonUserPermNameB = 'user_cannot_b'; $userRoleNameA = 'UserRoleA'; @@ -345,6 +448,8 @@ public function testAbilityShouldReturnArray() $permA = $this->mockPermission($userPermNameA); $permB = $this->mockPermission($userPermNameB); $permC = $this->mockPermission($userPermNameC); + $permD = $this->mockPermission($userPermNameD); + $permE = $this->mockPermission($userPermNameE); $roleA = $this->mockRole($userRoleNameA); $roleB = $this->mockRole($userRoleNameB); @@ -352,8 +457,9 @@ public function testAbilityShouldReturnArray() $roleA->perms = [$permA]; $roleB->perms = [$permB, $permC]; - $user = m::mock('HasRoleUser')->makePartial(); + $user = m::mock('HasRoleAndPermissionUser')->makePartial(); $user->roles = [$roleA, $roleB]; + $user->perms = [$permD,$permE]; $user->id = 4; $user->primaryKey = 'id'; @@ -363,12 +469,13 @@ public function testAbilityShouldReturnArray() | Expectation |------------------------------------------------------------ */ - $roleA->shouldReceive('cachedPermissions')->times(16)->andReturn($roleA->perms); - $roleB->shouldReceive('cachedPermissions')->times(12)->andReturn($roleB->perms); - Config::shouldReceive('get')->with('entrust.role_user_table')->times(32)->andReturn('role_user'); - Config::shouldReceive('get')->with('cache.ttl')->times(32)->andReturn('1440'); - Cache::shouldReceive('tags->remember')->times(32)->andReturn($user->roles); - Cache::shouldReceive('getStore')->times(32)->andReturn(new ArrayStore); + $roleA->shouldReceive('cachedPermissions')->andReturn($roleA->perms); + $roleB->shouldReceive('cachedPermissions')->andReturn($roleB->perms); + Config::shouldReceive('get')->with('entrust.role_user_table')->andReturn('role_user'); + Config::shouldReceive('get')->with('entrust.user_permission_table')->andReturn('user_permission'); + Config::shouldReceive('get')->with('cache.ttl')->andReturn('1440'); + Cache::shouldReceive('tags->remember')->andReturnUsing($this->setTagsRememberReturnUsing($user)); + Cache::shouldReceive('getStore')->andReturn(new ArrayStore); $user->shouldReceive('hasRole') ->with(m::anyOf($userRoleNameA, $userRoleNameB), m::anyOf(true, false)) @@ -498,6 +605,9 @@ public function testAbilityShouldReturnBoth() $userPermNameA = 'user_can_a'; $userPermNameB = 'user_can_b'; $userPermNameC = 'user_can_c'; + $userPermNameD = 'user_can_d'; + $userPermNameE = 'user_can_e'; + $nonUserPermNameA = 'user_cannot_a'; $nonUserPermNameB = 'user_cannot_b'; $userRoleNameA = 'UserRoleA'; @@ -508,6 +618,8 @@ public function testAbilityShouldReturnBoth() $permA = $this->mockPermission($userPermNameA); $permB = $this->mockPermission($userPermNameB); $permC = $this->mockPermission($userPermNameC); + $permD = $this->mockPermission($userPermNameD); + $permE = $this->mockPermission($userPermNameE); $roleA = $this->mockRole($userRoleNameA); $roleB = $this->mockRole($userRoleNameB); @@ -517,6 +629,7 @@ public function testAbilityShouldReturnBoth() $user = m::mock('HasRoleUser')->makePartial(); $user->roles = [$roleA, $roleB]; + $user->perms = [$permD,$permE]; $user->id = 4; $user->primaryKey = 'id'; @@ -525,12 +638,13 @@ public function testAbilityShouldReturnBoth() | Expectation |------------------------------------------------------------ */ - $roleA->shouldReceive('cachedPermissions')->times(16)->andReturn($roleA->perms); - $roleB->shouldReceive('cachedPermissions')->times(12)->andReturn($roleB->perms); - Config::shouldReceive('get')->with('entrust.role_user_table')->times(32)->andReturn('role_user'); - Config::shouldReceive('get')->with('cache.ttl')->times(32)->andReturn('1440'); - Cache::shouldReceive('tags->remember')->times(32)->andReturn($user->roles); - Cache::shouldReceive('getStore')->times(32)->andReturn(new ArrayStore); + $roleA->shouldReceive('cachedPermissions')->andReturn($roleA->perms); + $roleB->shouldReceive('cachedPermissions')->andReturn($roleB->perms); + Config::shouldReceive('get')->with('entrust.role_user_table')->andReturn('role_user'); + Config::shouldReceive('get')->with('entrust.user_permission_table')->andReturn('user_permission'); + Config::shouldReceive('get')->with('cache.ttl')->andReturn('1440'); + Cache::shouldReceive('tags->remember')->andReturnUsing($this->setTagsRememberReturnUsing($user)); + Cache::shouldReceive('getStore')->andReturn(new ArrayStore); $user->shouldReceive('hasRole') ->with(m::anyOf($userRoleNameA, $userRoleNameB), m::anyOf(true, false)) @@ -684,6 +798,8 @@ public function testAbilityShouldAcceptStrings() $permA = $this->mockPermission('user_can_a'); $permB = $this->mockPermission('user_can_b'); $permC = $this->mockPermission('user_can_c'); + $permD = $this->mockPermission('user_can_d'); + $permE = $this->mockPermission('user_can_e'); $roleA = $this->mockRole('UserRoleA'); $roleB = $this->mockRole('UserRoleB'); @@ -691,8 +807,9 @@ public function testAbilityShouldAcceptStrings() $roleA->perms = [$permA]; $roleB->perms = [$permB, $permC]; - $user = m::mock('HasRoleUser')->makePartial(); + $user = m::mock('HasRoleAndPermissionUser')->makePartial(); $user->roles = [$roleA, $roleB]; + $user->perms = [$permD,$permE]; $user->id = 4; $user->primaryKey = 'id'; @@ -701,12 +818,13 @@ public function testAbilityShouldAcceptStrings() | Expectation |------------------------------------------------------------ */ - $roleA->shouldReceive('cachedPermissions')->times(4)->andReturn($roleA->perms); - $roleB->shouldReceive('cachedPermissions')->times(2)->andReturn($roleB->perms); - Config::shouldReceive('get')->with('entrust.role_user_table')->times(8)->andReturn('role_user'); - Config::shouldReceive('get')->with('cache.ttl')->times(8)->andReturn('1440'); - Cache::shouldReceive('tags->remember')->times(8)->andReturn($user->roles); - Cache::shouldReceive('getStore')->times(8)->andReturn(new ArrayStore); + $roleA->shouldReceive('cachedPermissions')->andReturn($roleA->perms); + $roleB->shouldReceive('cachedPermissions')->andReturn($roleB->perms); + Config::shouldReceive('get')->with('entrust.role_user_table')->andReturn('role_user'); + Config::shouldReceive('get')->with('entrust.user_permission_table')->andReturn('user_permission'); + Config::shouldReceive('get')->with('cache.ttl')->andReturn('1440'); + Cache::shouldReceive('tags->remember')->andReturn($this->setTagsRememberReturnUsing($user)); + Cache::shouldReceive('getStore')->andReturn(new ArrayStore); $user->shouldReceive('hasRole') ->with(m::anyOf('UserRoleA', 'UserRoleB'), m::anyOf(true, false)) @@ -750,6 +868,8 @@ public function testAbilityDefaultOptions() $userPermNameA = 'user_can_a'; $userPermNameB = 'user_can_b'; $userPermNameC = 'user_can_c'; + $userPermNameD = 'user_can_d'; + $userPermNameE = 'user_can_e'; $nonUserPermNameA = 'user_cannot_a'; $nonUserPermNameB = 'user_cannot_b'; $userRoleNameA = 'UserRoleA'; @@ -760,6 +880,8 @@ public function testAbilityDefaultOptions() $permA = $this->mockPermission($userPermNameA); $permB = $this->mockPermission($userPermNameB); $permC = $this->mockPermission($userPermNameC); + $permD =$this->mockPermission($userPermNameD); + $permE = $this->mockPermission($userPermNameE); $roleA = $this->mockRole($userRoleNameA); $roleB = $this->mockRole($userRoleNameB); @@ -767,8 +889,9 @@ public function testAbilityDefaultOptions() $roleA->perms = [$permA]; $roleB->perms = [$permB, $permC]; - $user = m::mock('HasRoleUser')->makePartial(); + $user = m::mock('HasRoleAndPermissionUser')->makePartial(); $user->roles = [$roleA, $roleB]; + $user->perms = [$permD,$permE]; $user->id = 4; $user->primaryKey = 'id'; @@ -777,12 +900,13 @@ public function testAbilityDefaultOptions() | Expectation |------------------------------------------------------------ */ - $roleA->shouldReceive('cachedPermissions')->times(16)->andReturn($roleA->perms); - $roleB->shouldReceive('cachedPermissions')->times(12)->andReturn($roleB->perms); - Config::shouldReceive('get')->with('entrust.role_user_table')->times(32)->andReturn('role_user'); - Config::shouldReceive('get')->with('cache.ttl')->times(32)->andReturn('1440'); - Cache::shouldReceive('tags->remember')->times(32)->andReturn($user->roles); - Cache::shouldReceive('getStore')->times(32)->andReturn(new ArrayStore); + $roleA->shouldReceive('cachedPermissions')->andReturn($roleA->perms); + $roleB->shouldReceive('cachedPermissions')->andReturn($roleB->perms); + Config::shouldReceive('get')->with('entrust.role_user_table')->andReturn('role_user'); + Config::shouldReceive('get')->with('entrust.user_permission_table')->andReturn('user_permission'); + Config::shouldReceive('get')->with('cache.ttl')->andReturn('1440'); + Cache::shouldReceive('tags->remember')->andReturnUsing($this->setTagsRememberReturnUsing($user)); + Cache::shouldReceive('getStore')->andReturn(new ArrayStore); $user->shouldReceive('hasRole') ->with(m::anyOf($userRoleNameA, $userRoleNameB), m::anyOf(true, false)) @@ -1144,3 +1268,44 @@ public function belongsToMany($role, $assignedRolesTable) } } +class HasRoleAndPermissionUser implements EntrustUserInterface{ + use EntrustUserTrait; + public $roles; + public $perms; + public $primaryKey; + public $id; + + /** + * HasRoleAndPermissionUser constructor. + */ + public function __construct() + { + $this->primaryKey='id'; + $this->id=4; + } + + public function belongsToMany($roleOrPermission,$assignedRolesOrPermissionsTable){ + + } +} +class HasPermissionUser implements EntrustUserInterface{ + use EntrustUserTrait; + + public $perms; + public $primaryKey; + public $id; + + /** + * HasPermissionUser constructor. + */ + public function __construct() + { + $this->primaryKey='id'; + $this->id=4; + } + + public function belongsToMany($permission, $assignedPermissionsTable) + { + + } +}