Skip to content

Commit

Permalink
Updated casbin to 1.x.
Browse files Browse the repository at this point in the history
  • Loading branch information
leeqvip committed Aug 26, 2019
1 parent 1883034 commit 4e53d87
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/Adapters/DatabaseAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/Models/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -60,8 +60,6 @@ public function getAllFromCache()

/**
* Refresh Cache.
*
* @return void
*/
public function refreshCache()
{
Expand All @@ -75,8 +73,6 @@ public function refreshCache()

/**
* Forget Cache.
*
* @return void
*/
public function forgetCache()
{
Expand All @@ -85,8 +81,6 @@ public function forgetCache()

/**
* Init cache.
*
* @return void
*/
protected function initCache()
{
Expand Down

0 comments on commit 4e53d87

Please sign in to comment.