mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 02:04:03 +00:00
[4.x] Cleanup (#1317)
* cleanup, resolve todos, add immediate todos * Improve path_identification_middleware docblock * rename leave() method in tests * wip fix hardcoded values making assumptions about the parameters used in routing * defaultParameterNames * fix CreatesDatabaseUsers return values * $tenant -> tenant() * resolve more todos * make comment block a complete block * Correct useTenantRoutesInFortify(), delete unused import * test fixes * remove todos * remove JobPipeline todo * simplify comment example * remove todo * fix VERSION_PREFIX in queue.yml --------- Co-authored-by: lukinovec <lukinovec@gmail.com>
This commit is contained in:
parent
eac88dcc2a
commit
657e165cc8
23 changed files with 148 additions and 182 deletions
|
|
@ -85,6 +85,14 @@ class TenancyUrlGenerator extends UrlGenerator
|
|||
*/
|
||||
public static array $overrides = [];
|
||||
|
||||
/**
|
||||
* Use default parameter names ('tenant' name and tenant key value) instead of the parameter name
|
||||
* and column name configured in the path resolver config.
|
||||
*
|
||||
* You want to enable this when using query string identification while having customized that config.
|
||||
*/
|
||||
public static bool $defaultParameterNames = false;
|
||||
|
||||
/**
|
||||
* Override the route() method so that the route name gets prefixed
|
||||
* and the tenant parameter gets added when in tenant context.
|
||||
|
|
@ -166,7 +174,15 @@ class TenancyUrlGenerator extends UrlGenerator
|
|||
*/
|
||||
protected function addTenantParameter(array $parameters): array
|
||||
{
|
||||
return tenant() && static::$passTenantParameterToRoutes ? array_merge($parameters, [PathTenantResolver::tenantParameterName() => tenant()->getTenantKey()]) : $parameters;
|
||||
if (tenant() && static::$passTenantParameterToRoutes) {
|
||||
if (static::$defaultParameterNames) {
|
||||
return array_merge($parameters, ['tenant' => tenant()->getTenantKey()]);
|
||||
} else {
|
||||
return array_merge($parameters, [PathTenantResolver::tenantParameterName() => PathTenantResolver::tenantParameterValue(tenant())]);
|
||||
}
|
||||
} else {
|
||||
return $parameters;
|
||||
}
|
||||
}
|
||||
|
||||
protected function routeNameOverride(string $name): string|null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue