mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 14:14:04 +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
|
|
@ -145,24 +145,19 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
*/
|
||||
protected function overrideUrlInTenantContext(): void
|
||||
{
|
||||
/**
|
||||
* Import your tenant model!
|
||||
*
|
||||
* \Stancl\Tenancy\Bootstrappers\RootUrlBootstrapper::$rootUrlOverride = function (Tenant $tenant, string $originalRootUrl) {
|
||||
* $tenantDomain = $tenant instanceof \Stancl\Tenancy\Contracts\SingleDomainTenant
|
||||
* ? $tenant->domain
|
||||
* : $tenant->domains->first()->domain;
|
||||
*
|
||||
* $scheme = str($originalRootUrl)->before('://');
|
||||
*
|
||||
* // If you're using domain identification:
|
||||
* return $scheme . '://' . $tenantDomain . '/';
|
||||
*
|
||||
* // If you're using subdomain identification:
|
||||
* $originalDomain = str($originalRootUrl)->after($scheme . '://');
|
||||
* return $scheme . '://' . $tenantDomain . '.' . $originalDomain . '/';
|
||||
* };
|
||||
*/
|
||||
// \Stancl\Tenancy\Bootstrappers\RootUrlBootstrapper::$rootUrlOverride = function (Tenant $tenant, string $originalRootUrl) {
|
||||
// $tenantDomain = $tenant instanceof \Stancl\Tenancy\Contracts\SingleDomainTenant
|
||||
// ? $tenant->domain
|
||||
// : $tenant->domains->first()->domain;
|
||||
// $scheme = str($originalRootUrl)->before('://');
|
||||
//
|
||||
// // If you're using domain identification:
|
||||
// return $scheme . '://' . $tenantDomain . '/';
|
||||
//
|
||||
// // If you're using subdomain identification:
|
||||
// $originalDomain = str($originalRootUrl)->after($scheme . '://');
|
||||
// return $scheme . '://' . $tenantDomain . '.' . $originalDomain . '/';
|
||||
// };
|
||||
}
|
||||
|
||||
public function register()
|
||||
|
|
@ -178,32 +173,17 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
$this->makeTenancyMiddlewareHighestPriority();
|
||||
$this->overrideUrlInTenantContext();
|
||||
|
||||
/**
|
||||
* Include soft deleted resources in synced resource queries.
|
||||
*
|
||||
* ResourceSyncing\Listeners\UpdateOrCreateSyncedResource::$scopeGetModelQuery = function (Builder $query) {
|
||||
* if ($query->hasMacro('withTrashed')) {
|
||||
* $query->withTrashed();
|
||||
* }
|
||||
* };
|
||||
*/
|
||||
// // Include soft deleted resources in synced resource queries.
|
||||
// ResourceSyncing\Listeners\UpdateOrCreateSyncedResource::$scopeGetModelQuery = function (Builder $query) {
|
||||
// if ($query->hasMacro('withTrashed')) {
|
||||
// $query->withTrashed();
|
||||
// }
|
||||
// };
|
||||
|
||||
/**
|
||||
* To make Livewire v3 work with Tenancy, make the update route universal.
|
||||
*
|
||||
* Livewire::setUpdateRoute(function ($handle) {
|
||||
* return RouteFacade::post('/livewire/update', $handle)->middleware(['web', 'universal']);
|
||||
* });
|
||||
*/
|
||||
|
||||
// if (InitializeTenancyByRequestData::inGlobalStack()) {
|
||||
// FortifyRouteBootstrapper::$fortifyHome = 'dashboard';
|
||||
// TenancyUrlGenerator::$prefixRouteNames = false;
|
||||
// }
|
||||
|
||||
if (tenancy()->globalStackHasMiddleware(config('tenancy.identification.path_identification_middleware'))) {
|
||||
TenancyUrlGenerator::$prefixRouteNames = true;
|
||||
}
|
||||
// // To make Livewire v3 work with Tenancy, make the update route universal.
|
||||
// Livewire::setUpdateRoute(function ($handle) {
|
||||
// return RouteFacade::post('/livewire/update', $handle)->middleware(['web', 'universal', \Stancl\Tenancy::defaultMiddleware()]);
|
||||
// });
|
||||
}
|
||||
|
||||
protected function bootEvents()
|
||||
|
|
@ -228,10 +208,7 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
->group(base_path('routes/tenant.php'));
|
||||
}
|
||||
|
||||
// Delete this condition when using route-level path identification
|
||||
if (tenancy()->globalStackHasMiddleware(config('tenancy.identification.path_identification_middleware'))) {
|
||||
$this->cloneRoutes();
|
||||
}
|
||||
// $this->cloneRoutes();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -245,16 +222,13 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
/** @var CloneRoutesAsTenant $cloneRoutes */
|
||||
$cloneRoutes = $this->app->make(CloneRoutesAsTenant::class);
|
||||
|
||||
/**
|
||||
* You can provide a closure for cloning a specific route, e.g.:
|
||||
* $cloneRoutes->cloneUsing('welcome', function () {
|
||||
* RouteFacade::get('/tenant-welcome', fn () => 'Current tenant: ' . tenant()->getTenantKey())
|
||||
* ->middleware(['universal', InitializeTenancyByPath::class])
|
||||
* ->name('tenant.welcome');
|
||||
* });
|
||||
*
|
||||
* To see the default behavior of cloning the universal routes, check out the cloneRoute() method in CloneRoutesAsTenant.
|
||||
*/
|
||||
// // You can provide a closure for cloning a specific route, e.g.:
|
||||
// $cloneRoutes->cloneUsing('welcome', function () {
|
||||
// RouteFacade::get('/tenant-welcome', fn () => 'Current tenant: ' . tenant()->getTenantKey())
|
||||
// ->middleware(['universal', InitializeTenancyByPath::class])
|
||||
// ->name('tenant.welcome');
|
||||
// });
|
||||
// // To see the default behavior of cloning the universal routes, check out the cloneRoute() method in CloneRoutesAsTenant.
|
||||
|
||||
$cloneRoutes->handle();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue