From 7a7200fd250bd7aa7c748b62fdf51e7e01b54d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Sat, 16 May 2020 11:56:32 +0200 Subject: [PATCH] Minor fixes for using the package in an app --- assets/TenancyServiceProvider.stub.php | 10 ++++------ assets/config.php | 11 +++++++++-- src/Database/Models/Domain.php | 5 +---- src/Database/Models/Tenant.php | 4 ++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/assets/TenancyServiceProvider.stub.php b/assets/TenancyServiceProvider.stub.php index 9f49cf37..981a5df7 100644 --- a/assets/TenancyServiceProvider.stub.php +++ b/assets/TenancyServiceProvider.stub.php @@ -110,11 +110,9 @@ class TenancyServiceProvider extends ServiceProvider protected function mapRoutes() { - $this->app->booted(function () { - if (file_exists(base_path('routes/tenant.php'))) { - Route::namespace($this->app['config']['tenancy.tenant_route_namespace'] ?? 'App\Http\Controllers') - ->group(base_path('routes/tenant.php')); - } - }); + if (file_exists(base_path('routes/tenant.php'))) { + Route::namespace($this->app['config']['tenancy.tenant_route_namespace'] ?? 'App\Http\Controllers') + ->group(base_path('routes/tenant.php')); + } } } diff --git a/assets/config.php b/assets/config.php index 1e23b045..a875c083 100644 --- a/assets/config.php +++ b/assets/config.php @@ -176,13 +176,20 @@ return [ // Stancl\Tenancy\Features\CrossDomainRedirect::class, // https://tenancy.samuelstancl.me/docs/v2/features/tenant-redirect/ ], + /** + * Parameters used by the tenants:migrate command. + */ 'migration_parameters' => [ - '--force' => true, // Set this to true to be able to run migrations in production + '--force' => true, // This needs to be true to run migrations in production. '--path' => [database_path('migrations/tenant')], + '--realpath' => true, ], + /** + * Parameters used by the tenants:seed command. + */ 'seeder_parameters' => [ - '--class' => 'DatabaseSeeder', // root seeder class, e.g.: 'DatabaseSeeder' + '--class' => 'DatabaseSeeder', // root seeder class // '--force' => true, ], ]; diff --git a/src/Database/Models/Domain.php b/src/Database/Models/Domain.php index 5fe2b5b9..03af0d90 100644 --- a/src/Database/Models/Domain.php +++ b/src/Database/Models/Domain.php @@ -22,10 +22,7 @@ class Domain extends Model implements Contracts\Domain { use CentralConnection; - public $guarded = []; - public $casts = [ - 'is_primary' => 'bool', - ]; + protected $guarded = []; public static function booted() { diff --git a/src/Database/Models/Tenant.php b/src/Database/Models/Tenant.php index 761b4c07..234cfc9d 100644 --- a/src/Database/Models/Tenant.php +++ b/src/Database/Models/Tenant.php @@ -26,8 +26,8 @@ class Tenant extends Model implements Contracts\Tenant } protected $table = 'tenants'; - public $primaryKey = 'id'; - public $guarded = []; + protected $primaryKey = 'id'; + protected $guarded = []; public function getTenantKeyName(): string {