JosephSilber /保镖迁移如何运作?

时间:2016-08-07 11:52:18

标签: laravel laravel-5.1

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()是如何工作的?这个的目的是什么?

1 个答案:

答案 0 :(得分:2)

Bouncer可以让您customize its tables names

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

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

每当Bouncer需要一个表名时,它就会用Models::table($defaultTableName)来解析它from the Models class,以便它始终使用自定义表名。