{"record":{"id":"c1832b96db8805d4","repo":"spatie/laravel-permission","slug":"teams-feature-disabled-argument-team-id-has-no","errorCode":null,"errorMessage":"Teams feature disabled, argument --team-id has no effect. Either enable it in permissions config file or remove --team-id parameter","messagePattern":"Teams feature disabled, argument --team-id has no effect\\. Either enable it in permissions config file or remove --team-id parameter","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/Commands/AssignRoleCommand.php","lineNumber":29,"sourceCode":"{\n    protected $signature = 'permission:assign-role\n        {name : The name of the role}\n        {userId : The ID of the user to assign the role to}\n        {guard? : The name of the guard}\n        {userModelNamespace=App\\Models\\User : The fully qualified class name of the user model}\n        {--team-id=}';\n\n    protected $description = 'Assign a role to a user';\n\n    public function handle(PermissionRegistrar $permissionRegistrar): int\n    {\n        $roleName = $this->argument('name');\n        $userId = $this->argument('userId');\n        $guardName = $this->argument('guard');\n        $userModelClass = $this->argument('userModelNamespace');\n\n        if (! $permissionRegistrar->teams && $this->option('team-id')) {\n            $this->warn('Teams feature disabled, argument --team-id has no effect. Either enable it in permissions config file or remove --team-id parameter');\n\n            return self::SUCCESS;\n        }\n\n        // Validate that the model class exists and is instantiable\n        if (! class_exists($userModelClass)) {\n            $this->error(\"User model class [{$userModelClass}] does not exist.\");\n\n            return self::FAILURE;\n        }\n\n        $user = (new $userModelClass)::find($userId);\n\n        if (! $user) {\n            $this->error(\"User with ID {$userId} not found.\");\n\n            return self::FAILURE;\n        }","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/spatie/laravel-permission/blob/afd24018f68306e8b43ace487c107a59af1be776/src/Commands/AssignRoleCommand.php#L11-L47","documentation":"The permission:assign-role command accepts a --team-id option, but that option is only meaningful when the teams feature is on (PermissionRegistrar::$teams, driven by config('permission.teams')). When teams is disabled and --team-id is passed, the command prints this warning and returns SUCCESS immediately — no role is assigned at all. The early return prevents an assignment that would silently ignore the team scope the caller asked for.","triggerScenarios":"Running `php artisan permission:assign-role <name> <userId> <guard> <userModelNamespace> --team-id=X` while config('permission.teams') is false. The check is `$permissionRegistrar->teams && $this->option('team-id')`: any truthy --team-id value with the feature off triggers it.","commonSituations":"Copy-pasting a team-scoped command from a multi-tenant project into a single-tenant app; teams enabled in staging but disabled in production (or vice versa) so the same deploy script behaves differently; a leftover --team-id flag in a provisioning script after the teams feature was removed.","solutions":["Remove the --team-id option: php artisan permission:assign-role writer 1 web App\\Models\\User","If the assignment genuinely needs team scoping, enable teams first: set 'teams' => true in config/permission.php, run php artisan permission:setup-teams, migrate, then re-run the command with --team-id","Verify the effective flag with `php artisan tinker` → config('permission.teams'), and run php artisan config:clear after any config edit"],"exampleFix":"# before\nphp artisan permission:assign-role writer 1 web App\\Models\\User --team-id=2\n# exits 0 with the warning and assigns nothing\n\n# after (single-tenant app)\nphp artisan permission:assign-role writer 1 web App\\Models\\User","handlingStrategy":"validation","validationCode":"// build the command call without a dead --team-id option\n$teamsEnabled = app(\\Spatie\\Permission\\PermissionRegistrar::class)->teams;\n$args = [\n    'name' => 'writer',\n    'userId' => $user->id,\n    'guard' => 'web',\n    'userModelNamespace' => $user::class,\n];\n$options = ($teamsEnabled && $teamId) ? ['--team-id' => $teamId] : [];\n\\Illuminate\\Support\\Facades\\Artisan::call('permission:assign-role', $args + $options);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep --team-id out of shared scripts, or gate it on config('permission.teams') / PermissionRegistrar::class->teams","Remember this path exits 0 while assigning nothing — verify afterwards with $user->refresh()->hasRole('writer')","Keep the teams flag consistent across environments (committed config + env var) so one script cannot behave differently per host"],"tags":["laravel","artisan","spatie-permission","teams","cli","configuration"],"backgroundTag":"feature-flag-disabled","analyzedSha":"afd24018f68306e8b43ace487c107a59af1be776","analyzedAt":"2026-08-21T01:13:42.706Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}