Skip to content

Commit 4e53d87

Browse files
committed
Updated casbin to 1.x.
1 parent 1883034 commit 4e53d87

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

Diff for: composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"license": "Apache-2.0",
1212
"require": {
1313
"laravel/framework": "~5.1",
14-
"casbin/casbin": ">=0.2.1"
14+
"casbin/casbin": "~1.0"
1515
},
1616
"require-dev": {
1717
"phpunit/phpunit": "~5.7|~6.0|~7.0|~8.0",

Diff for: src/Adapters/DatabaseAdapter.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ public function loadPolicy($model)
6262
$rows = $this->eloquent->getAllFromCache();
6363

6464
foreach ($rows as $row) {
65-
$line = implode(', ', array_slice(array_values($row), 1));
65+
$line = implode(', ', array_filter($row, function ($val) {
66+
return '' != $val && !is_null($val);
67+
}));
6668
$this->loadPolicyLine(trim($line), $model);
6769
}
6870
}

Diff for: src/Models/Rule.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ public function __construct(array $attributes = [])
4444
/**
4545
* Gets rules from caches.
4646
*
47-
* @return void
47+
* @return mixed
4848
*/
4949
public function getAllFromCache()
5050
{
5151
$get = function () {
52-
return $this->get()->toArray();
52+
return $this->select('ptype', 'v0', 'v1', 'v2', 'v3', 'v4', 'v5')->get()->toArray();
5353
};
5454
if (!$this->config('cache.enabled', false)) {
5555
return $get();
@@ -60,8 +60,6 @@ public function getAllFromCache()
6060

6161
/**
6262
* Refresh Cache.
63-
*
64-
* @return void
6563
*/
6664
public function refreshCache()
6765
{
@@ -75,8 +73,6 @@ public function refreshCache()
7573

7674
/**
7775
* Forget Cache.
78-
*
79-
* @return void
8076
*/
8177
public function forgetCache()
8278
{
@@ -85,8 +81,6 @@ public function forgetCache()
8581

8682
/**
8783
* Init cache.
88-
*
89-
* @return void
9084
*/
9185
protected function initCache()
9286
{

0 commit comments

Comments
 (0)