Skip to content

Commit 54f9c54

Browse files
lucasmichotclaude
andcommitted
Fix tenants:seed command name via configure() (#1474)
Replaces the version_compare hack with a configure() override that sets the command name, which works regardless of whether the installed Laravel version's SeedCommand uses $name or $signature. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FFVB2qjYBoEB2q4NDBczs3
1 parent e0990a4 commit 54f9c54

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

src/Commands/Seed.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,28 @@ class Seed extends SeedCommand
1818

1919
public function __construct(ConnectionResolverInterface $resolver)
2020
{
21-
// See https://github.com/archtechx/tenancy/issues/1474
22-
if (version_compare(app()->version(), '13.24.0', '>=')) {
23-
$this->signature = 'tenants:seed
24-
{class? : The class name of the root seeder}
25-
{--class=Database\\Seeders\\DatabaseSeeder : The class name of the root seeder}
26-
{--database= : The database connection to seed}
27-
{--force : Force the operation to run when in production}';
28-
parent::__construct($resolver);
21+
parent::__construct($resolver);
22+
23+
// Our --tenants/--skip-tenants/--with-pending options only get added automatically
24+
// when the parent command isn't signature-based. Since Laravel 13.24, SeedCommand is,
25+
// so we add them ourselves here -- checking first so we don't add them twice on older
26+
// Laravel versions, where they're already there by this point.
27+
if (! $this->getDefinition()->hasOption('tenants')) {
2928
$this->specifyParameters();
30-
} else {
31-
$this->name = 'tenants:seed';
32-
parent::__construct($resolver);
3329
}
3430
}
3531

32+
protected function configure(): void
33+
{
34+
parent::configure();
35+
36+
// We inherit SeedCommand's name ('db:seed') since we don't redeclare $name/$signature,
37+
// so without this we'd overwrite Laravel's own db:seed command (see #1474). configure()
38+
// always runs after the name is set, regardless of Laravel version, so setting it here
39+
// is safe no matter which of $name/$signature the installed Laravel version uses.
40+
$this->setName('tenants:seed');
41+
}
42+
3643
public function handle(): int
3744
{
3845
foreach (config('tenancy.seeder_parameters') as $parameter => $value) {

0 commit comments

Comments
 (0)