Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

Commit 2a57a32

Browse files
committed
CasbinRule Model 增加name属性的配置
1 parent 046257f commit 2a57a32

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

config/casbin.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
// 数据库连接名称,不填为默认配置.
2424
'connection' => '',
2525

26-
// 策略表名.
27-
'casbin_rules_table' => 'casbin_rule',
26+
// 策略表名(不含表前缀)
27+
'casbin_rules_name' => 'casbin_rule',
28+
29+
// 策略表完整名称.
30+
'casbin_rules_table' => null,
2831
],
2932
];

database/migrations/20181113071924_casbin_rule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CasbinRule extends Migrator
2727
*/
2828
public function up()
2929
{
30-
$table = $this->table(config('casbin.database.casbin_rules_table'));
30+
$table = $this->table(config('casbin.database.casbin_rules_name'));
3131
$table->addColumn('ptype', 'string', ['null' => true])
3232
->addColumn('v0', 'string', ['null' => true])
3333
->addColumn('v1', 'string', ['null' => true])
@@ -40,7 +40,7 @@ public function up()
4040

4141
public function down()
4242
{
43-
$table = $this->table(config('casbin.database.casbin_rules_table'));
43+
$table = $this->table(config('casbin.database.casbin_rules_name'));
4444
$table->delete();
4545
}
4646
}

src/Models/CasbinRule.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ class CasbinRule extends Model
88
{
99
public function __construct($data = [])
1010
{
11-
parent::__construct($data);
12-
13-
//TODO:初始化内容
1411
$this->connection = config('casbin.database.connection') ?: '';
1512

1613
$this->table = config('casbin.database.casbin_rules_table');
14+
15+
$this->name = config('casbin.database.casbin_rules_name');
16+
17+
parent::__construct($data);
1718
}
1819
}

0 commit comments

Comments
 (0)