automaticaly assign guard_name

This commit is contained in:
Geriano
2022-10-30 19:31:55 +07:00
parent 80555c27a9
commit 37ca06b6fc
2 changed files with 20 additions and 1 deletions

View File

@@ -6,5 +6,18 @@ use Spatie\Permission\Models\Role as Model;
class Role extends Model
{
//
/**
* @inheritdoc
*/
public static function boot()
{
parent::boot();
static::bootTraits();
static::creating(function (Role $role) {
if (!$role->guard_name) {
$role->guard_name = 'web';
}
});
}
}