diff --git a/composer.json b/composer.json index e433f0a..cbe803b 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "license": "Apache-2.0", "require": { "laravel/framework": "~5.1", - "casbin/casbin": ">=0.2.1" + "casbin/casbin": "~1.0" }, "require-dev": { "phpunit/phpunit": "~5.7|~6.0|~7.0|~8.0", diff --git a/src/Adapters/DatabaseAdapter.php b/src/Adapters/DatabaseAdapter.php index a025402..94881d9 100644 --- a/src/Adapters/DatabaseAdapter.php +++ b/src/Adapters/DatabaseAdapter.php @@ -62,7 +62,9 @@ public function loadPolicy($model) $rows = $this->eloquent->getAllFromCache(); foreach ($rows as $row) { - $line = implode(', ', array_slice(array_values($row), 1)); + $line = implode(', ', array_filter($row, function ($val) { + return '' != $val && !is_null($val); + })); $this->loadPolicyLine(trim($line), $model); } } diff --git a/src/Models/Rule.php b/src/Models/Rule.php index 26e4181..c02cd66 100644 --- a/src/Models/Rule.php +++ b/src/Models/Rule.php @@ -44,12 +44,12 @@ public function __construct(array $attributes = []) /** * Gets rules from caches. * - * @return void + * @return mixed */ public function getAllFromCache() { $get = function () { - return $this->get()->toArray(); + return $this->select('ptype', 'v0', 'v1', 'v2', 'v3', 'v4', 'v5')->get()->toArray(); }; if (!$this->config('cache.enabled', false)) { return $get(); @@ -60,8 +60,6 @@ public function getAllFromCache() /** * Refresh Cache. - * - * @return void */ public function refreshCache() { @@ -75,8 +73,6 @@ public function refreshCache() /** * Forget Cache. - * - * @return void */ public function forgetCache() { @@ -85,8 +81,6 @@ public function forgetCache() /** * Init cache. - * - * @return void */ protected function initCache() {