diff --git a/assets/config.php b/assets/config.php index 844b8d93..5624143c 100644 --- a/assets/config.php +++ b/assets/config.php @@ -226,7 +226,7 @@ return [ // Stancl\Tenancy\Features\Timestamps::class, // https://tenancy.samuelstancl.me/docs/v2/features/timestamps/ // Stancl\Tenancy\Features\TenantConfig::class, // https://tenancy.samuelstancl.me/docs/v2/features/tenant-config/ // Stancl\Tenancy\Features\TelescopeTags::class, // https://tenancy.samuelstancl.me/docs/v2/telescope/ - // Stancl\Tenancy\Features\TenantRedirect::class, // https://tenancy.samuelstancl.me/docs/v2/features/tenant-redirect/ + // Stancl\Tenancy\Features\CrossDomainRedirect::class, // https://tenancy.samuelstancl.me/docs/v2/features/tenant-redirect/ ], 'storage_to_config_map' => [ // Used by the TenantConfig feature // 'paypal_api_key' => 'services.paypal.api_key', diff --git a/src/Features/TenantRedirect.php b/src/Features/CrossDomainRedirect.php similarity index 85% rename from src/Features/TenantRedirect.php rename to src/Features/CrossDomainRedirect.php index 26fb1b08..8eecaeee 100644 --- a/src/Features/TenantRedirect.php +++ b/src/Features/CrossDomainRedirect.php @@ -8,11 +8,11 @@ use Illuminate\Http\RedirectResponse; use Stancl\Tenancy\Contracts\Feature; use Stancl\Tenancy\TenantManager; -class TenantRedirect implements Feature +class CrossDomainRedirect implements Feature { public function bootstrap(TenantManager $tenantManager): void { - RedirectResponse::macro('tenant', function (string $domain) { + RedirectResponse::macro('domain', function (string $domain) { // replace first occurance of hostname fragment with $domain $url = $this->getTargetUrl(); $hostname = parse_url($url, PHP_URL_HOST); diff --git a/tests/RedirectTest.php b/tests/RedirectTest.php index c0bd90a8..ededb239 100644 --- a/tests/RedirectTest.php +++ b/tests/RedirectTest.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Stancl\Tenancy\Tests; use Route; +use Stancl\Tenancy\Features\CrossDomainRedirect; use Stancl\Tenancy\Tenant; class RedirectTest extends TestCase @@ -16,7 +17,7 @@ class RedirectTest extends TestCase public function tenant_redirect_macro_replaces_only_the_hostname() { config([ - 'tenancy.features' => ['Stancl\Tenancy\Features\TenantRedirect'], + 'tenancy.features' => [CrossDomainRedirect::class], ]); Route::get('/foobar', function () { @@ -24,7 +25,7 @@ class RedirectTest extends TestCase })->name('home'); Route::get('/redirect', function () { - return redirect()->route('home')->tenant('abcd'); + return redirect()->route('home')->domain('abcd'); }); Tenant::create('foo.localhost');