Esempio n. 1
0
 /**
  * Setup the database schema.
  *
  * @return void
  */
 public function setUp()
 {
     Role::$userModel = User::class;
     Ability::$userModel = User::class;
     $this->schema()->create('users', function ($table) {
         $table->increments('id');
         $table->timestamps();
     });
     $this->schema()->create('abilities', function ($table) {
         $table->increments('id');
         $table->string('title');
         $table->integer('entity_id')->unsigned()->nullable();
         $table->string('entity_type')->nullable();
         $table->timestamps();
         $table->unique(['title', 'entity_id', 'entity_type']);
     });
     $this->schema()->create('roles', function ($table) {
         $table->increments('id');
         $table->string('title')->unique();
         $table->timestamps();
     });
     $this->schema()->create('user_roles', function ($table) {
         $table->integer('role_id')->unsigned();
         $table->integer('user_id')->unsigned();
     });
     $this->schema()->create('user_abilities', function ($table) {
         $table->integer('ability_id')->unsigned();
         $table->integer('user_id')->unsigned();
     });
     $this->schema()->create('role_abilities', function ($table) {
         $table->integer('ability_id')->unsigned();
         $table->integer('role_id')->unsigned();
     });
 }
Esempio n. 2
0
 /**
  * Set the name of the user model on the role and Ability classes.
  *
  * @return void
  */
 protected function setUserModel()
 {
     $model = $this->app->make('config')->get('auth.model');
     Ability::$userModel = $model;
     Role::$userModel = $model;
 }