JosephSilber/bouncer 迁移如何进行?

How does JosephSilber/bouncer migration work?

Schema::create(Models::table('abilities'), function (Blueprint $table) {
     $table->increments('id');
     $table->string('name');
     $table->integer('entity_id')->unsigned()->nullable();
     $table->string('entity_type')->nullable();
     $table->timestamps();
     $table->unique(['name', 'entity_id', 'entity_type']);
});

这个 Models::table() 是如何工作的?这样做的目的是什么?

Bouncer 让您 customize its tables names:

Bouncer::tables([
    'abilities' => 'my_abilities',
    'permissions' => 'granted_abilities',
]);

当您这样做时,Bouncer 将存储自定义 table 名称 in its Models class

只要 Bouncer 需要 table 名称,它就会将其 from the Models class 解析为 Models::table($defaultTableName),因此它始终使用自定义 table 名称。