/** * Execute the console command. * * @return mixed */ public function handle() { $model = Authorization::role(); $label = $this->argument('label'); $name = str_slug($label); $exists = $model->whereName($name)->first(); if (!$exists) { $model::forceCreate(['name' => $name, 'label' => $label]); $this->info("Successfully created role: {$name}."); } else { $this->error("A role named {$label} already exists."); } }
public function test_role_helper() { config()->set('authorization.role', Role::class); $this->assertInstanceOf(Role::class, Authorization::role()); }
/** * A model may have multiple roles. * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function roles() { $model = get_class(Authorization::role()); return $this->belongsToMany($model); }