When syncing resources, this line $centralModel = $event->model->getCentralModelName()::create($event->model->getAttributes()); fails in two situations:
1. when there are column(s) in tenant table that are not in central table.
2. when there is already a row in central table with same id as the id generated while creating the model on tenant table(With ID i mean primary key which my differ from Global ID column).
With this change, only syncedAttributes will be used while creating the model on central table. unfortunately, with this we lose the ability to populate the row with default values and all required columns must be on $syncedAttributes, but is the only way I could get it to work.
* Add option to enable/disable tenant asset route
* Only registers tenant route if enabled in config
* Uses proper config key
* Move routes config option
* Move config to service provider
* Moves config to service provider
* Instead of querying Domain model, find Tenant and eager load it's domain via Tenant model. Fixed cached lookup issue - when caching Tenant, also include the current Domain, so it can be later accessed via $tenant->domains->first() (even, when using multiple domains per tenant). Added tenantIdentifiedFromCache method in CachedTenantResolver.php, which can be used to set custom properties in resolvers after Tenant is loaded from cache.
* StlyeCi Fix - removed PHP 8 nullsafe operator for compatibility with older PHP versions, replaced with inline if
* Redundant variable '$domain', because $tenant is not null, only, when current domain is found and relationship is loaded (with only one domain).
* Fixed tenant()->domains showing incorrect data. Renamed tenantIdentifiedFromCache() method and removed duplicate code, when setting current domain.
* Removed select() for better flexibility, added new method setCurrentDomain(), refactored the usage of tenantIdentified().
* rename method to resolved()
* clean up code
* StyleCi Fix
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* PHP 8 support, test workflow syntax
* Try using a custom data structure in the workflow
* Try using matrix include
* Default PHP target
* single include
* fix composer package name
* [WIP] Try using dev-master for valuestore
* Update spatie/valuestore constraint to be stable
* Fix issue 521: Array input for `--tenants`
Tenancy for Laravel docs refer to using multiple `--tenants=<...> ` options when running a command for multiple tenants explicitly: https://tenancyforlaravel.com/docs/v3/console-commands
However, the command input is not defined correctly to receive arrays.
https://laravel.com/docs/7.x/artisan#input-arrays
This PR adds a failing test, fixes the issue and corrects a typo in the contributing readme.
* Styleci
Co-authored-by: Dylan Harbour <dylanh@ringier.co.za>
* Fix: The database name is displayed when the TenantDatabaseAlreadyExistsException exception is thrown.
* Fix the code style
Co-authored-by: Henrich <Ekoumelong>
* Modified GeneratesIds.php
When overwriting `getTenantKeyName()` to use another column, an exception occurs when creating new tenants. (Field 'id' doesn't have a default value).
This fixes the issue.
* Fix style
Co-authored-by: Samuel Stancl <samuel.stancl@gmail.com>