Skip to content

Commit e0990a4

Browse files
authored
Laravel 13.24 support (fix #1474) (#1476)
- We conditionally use either $signature + specifyParameters() in the newer versions or just $name in the older versions. There doesn't appear to be a single solution that'd work in both versions, likely having to do with the constructor override in the trait and how the specifyParameters() method behaves differently in this class between versions - Remove unnecessary options from the Run command (the trait adds those) - Not directly related: make HasTenantOptions accept ...$args - Unrelated: remove phpstan ignore in TenancyServiceProvider
1 parent 553f57a commit e0990a4

4 files changed

Lines changed: 17 additions & 9 deletions

File tree

src/Commands/Run.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ class Run extends Command
1616

1717
protected $description = 'Run a command for tenant(s)';
1818

19-
protected $signature = 'tenants:run {commandname : The artisan command.}
20-
{--tenants=* : The tenant(s) to run the command for. Default: all}
21-
{--skip-tenants=* : The tenant(s) to skip}';
19+
protected $signature = 'tenants:run {commandname : The artisan command.}';
2220

2321
public function handle(): int
2422
{

src/Commands/Seed.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,21 @@ class Seed extends SeedCommand
1616

1717
protected $description = 'Seed tenant database(s).';
1818

19-
protected $name = 'tenants:seed';
20-
2119
public function __construct(ConnectionResolverInterface $resolver)
2220
{
23-
parent::__construct($resolver);
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);
29+
$this->specifyParameters();
30+
} else {
31+
$this->name = 'tenants:seed';
32+
parent::__construct($resolver);
33+
}
2434
}
2535

2636
public function handle(): int

src/Concerns/HasTenantOptions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ protected function getTenantsQuery(?array $tenantKeys = null): Builder
5555
});
5656
}
5757

58-
public function __construct()
58+
public function __construct(mixed ...$args)
5959
{
60-
parent::__construct();
60+
parent::__construct(...$args);
6161

6262
$this->specifyParameters();
6363
}

src/TenancyServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function register(): void
103103
$config['connection'] ??= $centralConnection;
104104

105105
/** @var CacheManager $this */
106-
return $this->createDatabaseDriver($config); // @phpstan-ignore method.protected
106+
return $this->createDatabaseDriver($config);
107107
});
108108

109109
// DatabaseCacheBootstrapper explicitly writes 'tenant' into each store's 'connection'

0 commit comments

Comments
 (0)