{"id":"3df4a7b3bc63d0bd","repo":"laravel/framework","slug":"the-model-and-except-options-cannot-be-combine","errorCode":null,"errorMessage":"The --model and --except options cannot be combined.","messagePattern":"The --model and --except options cannot be combined\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Console/PruneCommand.php","lineNumber":124,"sourceCode":"        if ($total == 0) {\n            $this->components->info(\"No prunable [$model] records found.\");\n        }\n    }\n\n    /**\n     * Determine the models that should be pruned.\n     *\n     * @return \\Illuminate\\Support\\Collection\n     *\n     * @throws \\InvalidArgumentException\n     */\n    protected function models()\n    {\n        $models = $this->option('model');\n        $except = $this->option('except');\n\n        if ($models && $except) {\n            throw new InvalidArgumentException('The --model and --except options cannot be combined.');\n        }\n\n        if ($models) {\n            return (new Collection($models))\n                ->filter(static fn (string $model) => class_exists($model))\n                ->values();\n        }\n\n        return (new Collection(Finder::create()->in($this->getPath())->files()->name('*.php')))\n            ->map(function ($model) {\n                $namespace = $this->laravel->getNamespace();\n\n                return $namespace.str_replace(\n                    ['/', '.php'],\n                    ['\\\\', ''],\n                    Str::after($model->getRealPath(), realpath(app_path()).DIRECTORY_SEPARATOR)\n                );\n            })","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Database/Console/PruneCommand.php#L106-L142","documentation":"Thrown by PruneCommand::models() when the artisan model:prune command is invoked with both --model and --except at the same time. The two flags are mutually exclusive ways to scope which models get pruned; combining them is ambiguous.","triggerScenarios":"Running `php artisan model:prune --model=App\\Models\\Post --except=App\\Models\\Draft`. The command parses both options, sees they are both truthy, and throws InvalidArgumentException before scanning.","commonSituations":"Copy-pasting flags from different invocations; scripting a cron job that layers both options; shell glob/alias accidentally appending --except.","solutions":["Use only --model to prune an explicit list, or only --except to prune all-but-a-list.","If you need 'everything except X', drop --model and keep --except.","If you need a specific subset, list it fully with --model and omit --except.","Inspect the command help: php artisan model:prune -h to confirm mutually exclusive options."],"exampleFix":"# before\nphp artisan model:prune --model=\"App\\Models\\Post\" --except=\"App\\Models\\Draft\"\n\n# after\nphp artisan model:prune --except=\"App\\Models\\Draft\"","handlingStrategy":"validation","validationCode":"if (! empty($modelOption) && ! empty($exceptOption)) {\n    throw new \\InvalidArgumentException('Pass either --model or --except, not both.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document the mutual exclusivity of --model/--except in runbooks.","Wrap scripted prune calls in a helper that rejects both flags.","Review cron entries that combine flags from copy-paste.","Run php artisan model:prune -h to confirm option semantics."],"tags":["console","eloquent","cli","validation"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}