is_system) { throw new RuntimeException('System roles cannot be deleted.'); } }); static::updating(function (Role $role): void { if ((bool) $role->getOriginal('is_system') && ($role->isDirty('name') || $role->isDirty('is_system'))) { throw new RuntimeException('System roles cannot be renamed or demoted.'); } }); } protected function casts(): array { return [ 'is_system' => 'boolean', 'is_administrator' => 'boolean', 'client_scoped' => 'boolean', ]; } /** * @return HasMany */ public function permissions(): HasMany { return $this->hasMany(RolePermission::class); } /** * @return HasMany */ public function users(): HasMany { return $this->hasMany(User::class); } }