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

Commit

Permalink
CasbinRule Model 增加name属性的配置
Browse files Browse the repository at this point in the history
  • Loading branch information
leeqvip committed Dec 29, 2018
1 parent 046257f commit 2a57a32
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions config/casbin.php
Expand Up @@ -23,7 +23,10 @@
// 数据库连接名称,不填为默认配置.
'connection' => '',

// 策略表名.
'casbin_rules_table' => 'casbin_rule',
// 策略表名(不含表前缀)
'casbin_rules_name' => 'casbin_rule',

// 策略表完整名称.
'casbin_rules_table' => null,
],
];
4 changes: 2 additions & 2 deletions database/migrations/20181113071924_casbin_rule.php
Expand Up @@ -27,7 +27,7 @@ class CasbinRule extends Migrator
*/
public function up()
{
$table = $this->table(config('casbin.database.casbin_rules_table'));
$table = $this->table(config('casbin.database.casbin_rules_name'));
$table->addColumn('ptype', 'string', ['null' => true])
->addColumn('v0', 'string', ['null' => true])
->addColumn('v1', 'string', ['null' => true])
Expand All @@ -40,7 +40,7 @@ public function up()

public function down()
{
$table = $this->table(config('casbin.database.casbin_rules_table'));
$table = $this->table(config('casbin.database.casbin_rules_name'));
$table->delete();
}
}
7 changes: 4 additions & 3 deletions src/Models/CasbinRule.php
Expand Up @@ -8,11 +8,12 @@ class CasbinRule extends Model
{
public function __construct($data = [])
{
parent::__construct($data);

//TODO:初始化内容
$this->connection = config('casbin.database.connection') ?: '';

$this->table = config('casbin.database.casbin_rules_table');

$this->name = config('casbin.database.casbin_rules_name');

parent::__construct($data);
}
}

0 comments on commit 2a57a32

Please sign in to comment.