1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-15 02:24:04 +00:00

[2.1.0] Initialize tenancy before executing controller constructors (#169)

* Update message about migrations in Install

* wip

* Apply fixes from StyleCI

* string instead of array

* Fix globalUrl binding

* Simplify if condition in TenantRouteServiceProvider

* Apply fixes from StyleCI

* Improve PreventAccessFromTenantDomains - look into middleware subgroups

* Fix typo

* gatherMiddleware() instead of middleware()

* Fix tests

* Apply fixes from StyleCI

* Update install command

* Apply fixes from StyleCI

* Add the PreventAccess MW to tenant routes by default
This commit is contained in:
Samuel Štancl 2019-10-15 20:23:56 +02:00 committed by GitHub
parent 7143bce5f9
commit cbd3850a8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 66 additions and 22 deletions

View file

@ -47,6 +47,9 @@ class Install extends Command
$newKernel = str_replace("'web' => [", "'web' => [
\Stancl\Tenancy\Middleware\PreventAccessFromTenantDomains::class,", $newKernel);
$newKernel = str_replace("'api' => [", "'api' => [
\Stancl\Tenancy\Middleware\PreventAccessFromTenantDomains::class,", $newKernel);
file_put_contents(app_path('Http/Kernel.php'), $newKernel);
$this->info('✔️ Set middleware priority');
@ -59,9 +62,9 @@ class Install extends Command
| Tenant Routes
|--------------------------------------------------------------------------
|
| Here is where you can register tenant routes for your application. These
| routes are loaded by the TenantRouteServiceProvider within a group
| which contains the \"InitializeTenancy\" middleware. Good luck!
| Here you can register the tenant routes for your application.
| These routes are loaded by the TenantRouteServiceProvider
| with the tenancy and web middleware groups. Good luck!
|
*/
@ -73,11 +76,11 @@ Route::get('/app', function () {
$this->info('✔️ Created routes/tenant.php');
$this->line('');
$this->line("This package lets you store data about tenants either in Redis or in a relational database like MySQL. If you're going to use the database storage, you need to create a tenants table.");
if ($this->confirm('Do you want to publish the default database migrations?', true)) {
$this->line('This package lets you store data about tenants either in Redis or in a relational database like MySQL. To store data about tenants in a relational database, you need a few database tables.');
if ($this->confirm('Do you wish to publish the migrations that create these tables?', true)) {
$this->callSilent('vendor:publish', [
'--provider' => 'Stancl\Tenancy\TenancyServiceProvider',
'--tag' => 'migrations',
'--provider' => 'Stancl\Tenancy\TenancyServiceProvider',
'--tag' => 'migrations',
]);
$this->info('✔️ Created migrations. Remember to run [php artisan migrate]!');
}