mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 06:04:03 +00:00
Different installation for Laravel 7
This commit is contained in:
parent
d1991fdd61
commit
1210c0dd5f
1 changed files with 31 additions and 7 deletions
|
|
@ -36,13 +36,7 @@ class Install extends Command
|
|||
]);
|
||||
$this->info('✔️ Created config/tenancy.php');
|
||||
|
||||
$newKernel = str_replace(
|
||||
'protected $middlewarePriority = [',
|
||||
"protected \$middlewarePriority = [
|
||||
\Stancl\Tenancy\Middleware\PreventAccessFromTenantDomains::class,
|
||||
\Stancl\Tenancy\Middleware\InitializeTenancy::class,",
|
||||
file_get_contents(app_path('Http/Kernel.php'))
|
||||
);
|
||||
$newKernel = $this->setMiddlewarePriority();
|
||||
|
||||
$newKernel = str_replace("'web' => [", "'web' => [
|
||||
\Stancl\Tenancy\Middleware\PreventAccessFromTenantDomains::class,", $newKernel);
|
||||
|
|
@ -77,4 +71,34 @@ class Install extends Command
|
|||
|
||||
$this->comment('✨️ stancl/tenancy installed successfully.');
|
||||
}
|
||||
|
||||
protected function setMiddlewarePriority(): string
|
||||
{
|
||||
if (app()->version()[0] === '6') {
|
||||
return str_replace(
|
||||
'protected $middlewarePriority = [',
|
||||
"protected \$middlewarePriority = [
|
||||
\Stancl\Tenancy\Middleware\PreventAccessFromTenantDomains::class,
|
||||
\Stancl\Tenancy\Middleware\InitializeTenancy::class,",
|
||||
file_get_contents(app_path('Http/Kernel.php'))
|
||||
);
|
||||
} else {
|
||||
return str_replace(
|
||||
'];\n}',
|
||||
"protected \$middlewarePriority = [
|
||||
\App\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\Stancl\Tenancy\Middleware\PreventAccessFromTenantDomains::class,
|
||||
\Stancl\Tenancy\Middleware\InitializeTenancy::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\Illuminate\Contracts\Auth\Middleware\AuthenticatesRequests::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
\Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\Illuminate\Auth\Middleware\Authorize::class,
|
||||
];",
|
||||
file_get_contents(app_path('Http/Kernel.php'))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue