mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 15:14:04 +00:00
wip
This commit is contained in:
parent
9520cbc811
commit
36afb7dbdd
4 changed files with 29 additions and 0 deletions
|
|
@ -283,6 +283,9 @@ return [
|
|||
// Stancl\Tenancy\Features\TelescopeTags::class,
|
||||
// Stancl\Tenancy\Features\UniversalRoutes::class,
|
||||
// Stancl\Tenancy\Features\TenantConfig::class, // https://tenancyforlaravel.com/docs/v3/features/tenant-config
|
||||
],
|
||||
|
||||
'tenant_unaware_features' => [
|
||||
// Stancl\Tenancy\Features\CrossDomainRedirect::class, // https://tenancyforlaravel.com/docs/v3/features/cross-domain-redirect
|
||||
],
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ use Stancl\Tenancy\Tenancy;
|
|||
|
||||
class CrossDomainRedirect implements Feature
|
||||
{
|
||||
public function __construct(protected Tenancy $tenancy)
|
||||
{
|
||||
dd($this->tenancy);
|
||||
}
|
||||
|
||||
public function bootstrap(Tenancy $tenancy): void
|
||||
{
|
||||
RedirectResponse::macro('domain', function (string $domain) {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
return $tenancy;
|
||||
});
|
||||
|
||||
foreach ($this->app['config']['tenancy.tenant_unaware_features'] ?? [] as $feature) {
|
||||
$this->app[$feature]->bootstrap();
|
||||
}
|
||||
|
||||
// Make it possible to inject the current tenant by typehinting the Tenant contract.
|
||||
$this->app->bind(Tenant::class, function ($app) {
|
||||
return $app[Tenancy::class]->tenant;
|
||||
|
|
|
|||
|
|
@ -34,3 +34,20 @@ test('tenant route helper generates correct url', function () {
|
|||
expect(tenant_route('foo.localhost', 'foo', ['a' => 'as', 'b' => 'df']))->toBe('http://foo.localhost/abcdef/as/df');
|
||||
expect(tenant_route('foo.localhost', 'foo', []))->toBe('http://foo.localhost/abcdef');
|
||||
});
|
||||
|
||||
test('redirect from central to tenant works fine', function () {
|
||||
config([
|
||||
'tenancy.features' => [CrossDomainRedirect::class],
|
||||
]);
|
||||
|
||||
Route::get('/foobar', function () {
|
||||
return 'Foo';
|
||||
})->name('home');
|
||||
|
||||
Route::get('/redirect', function () {
|
||||
return redirect()->route('home')->domain('abcd');
|
||||
});
|
||||
|
||||
pest()->get('/redirect')
|
||||
->assertRedirect('http://abcd/foobar');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue