* Add and test Migrate command's skip-failing option
* Improve naming
* Move migration event dispatching inside try block
* Change test name
* Fix skip-failing test
* Use QueryException instead of Exception
* Correct TenantDatabaseDoesNotExistException import
* Correct test
* Check for the the testing env in DB bootstrapper
* Correct the Migrate command
* Fix code style (php-cs-fixer)
* add docs todo
* Add QueryException to the Migrat command try/catch
* Return status codes in Migrate
* Fix code style (php-cs-fixer)
* Add test for not stopping tenants:migrate after the first failure
* Update Migrate command
* Fix code style (php-cs-fixer)
* Fix code style (php-cs-fixer)
* Use `getTenants()`
* Use withtenantDatabases where needed
* Add withTenantDatabases to test
---------
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Replace MailManager singleton with an instance of a custom mail manager which always resolves the mailers instead of getting the cached ones
* Fix code style (php-cs-fixer)
* Add MailTenancyBootstrapper
* Add MailTenancyBootstrapper to tenancy.bootstrappers config (commented out)
* Fix code style (php-cs-fixer)
* Make credentials map a public static property
* Always resolve only the mailers specified in the mailersToNotCache public static property
* Fix typo in comment
* Update TenancyServiceProvider comment
* add todo
* Add comments to TenancyMailManager, rename property
* Remove the configKey array check
* Simplify bootstrap method
* Change $credentialsMap so that config keys are the keys, and the tenant property names are the values
* Rename $mailersToAlwaysResolve to $tenantMailers
* Update comment
* Update comment
* Rename variable in TenancyServiceProvider comment
* Scaffold tests
* Update comments after review
* Uncomment MailTenancyBootstrapper in config
* Use array_key_exists instead of null check
* Split config logic into methods
* Update mapping credentials
* Add tests for the added logic
* Fix code style (php-cs-fixer)
* Delete default 'smtp' mailer in $tenantMailers
* Add separate method to pick the appropriate mail credentials map preset
* Specify test name
* Move mail bootstrapper tests to BootstrapperTest
* Depend less on the default mailer by adding a static `$mailer` property
* Use static property for map presets
* Comment out MailTenancyBootstrapper from config
* Add return types to MailTenancyBootstrapper methods
* Update test name
* Move MailManager extension to MailTenancyBootstrapper
* Fix code style (php-cs-fixer)
* Update config reverting test
* Use `invade()` instead of ReflectionClass
* Fix constructor parameter formatting
* Delete TenancyMailManager, update tests
* Add return type
* Update comment
* Update MailTest
* Delete `group('mailer')`
* Delete bindNewMailManagerInstance()
* Delete remaining `group('mailer')`
* Fix comment
* Fix comment
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Add SessionTenancyBootstrapper
* Fix code style (php-cs-fixer)
* add value to bootstrappers config
* tenant aware call test
* reproduce issue in tests
* fix logic for calling tenant run from central context, finish tests
* change laravel version back
* bump laravel to ^9.38
* add listener to create tenant DBs
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>
* wip
* Improve tests
* rename class
* wip
* improve tests
* introduce early identification middlewares
* Update PreventAccessFromCentralDomains.php
* method rename
* method rename
* Update UniversalRouteTest.php
* Update UniversalRouteTest.php
* Update EarlyIdentificationTest.php
* remove early classes and add check in existing classes
* MWs improvements
* Update UniversalRouteTest.php
* Fix code style (php-cs-fixer)
* trigger ci
* fix failing test after merge
* add test for universal route in early identification
* Update InitializeTenancyByDomain.php
* Update UniversalRouteTest.php
* remove `routeHasMiddleware` method from MW and use the UniversalRoutes class method
* helper dockblock
* add test
* handle universal routes in early identification
* remove UniversalRoute class because we are not using it anymore
* rename class from PreventAccessFromCentralDomains to PreventAccessFromUnwantedDomains
* improvements after self review
* Update PreventAccessFromUnwantedDomains.php
* remove inline class namespaces
* remove DomainTenant class and use the Tenant class
* update comment
* removed custom expection and add method
* Update tests/EarlyIdentificationTest.php
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* use ltrim and simplify the comment
* remove comments and typhint
* dataset and keys rename
* rename $route parameter
* removed helper functions
* fix style
* Update InitializeTenancyByPath.php
* Update tests/EarlyIdentificationTest.php
* code style
* improve subdomain test
* use TenancyInitialized event and remove DomainTenant alias
* remove comment and move expectException below
* code style
* use TenancyInitialized event
* improve test
* improve datasets
* Initialized -> Initializing
* Update InitializeTenancyByPath.php
* remove todo
* Fix code style (php-cs-fixer)
* refactor helper method
* Update UniversalRouteTest.php
* add note above test
* remove after each hook
* renamed universal_middleware to global_middleware
* remove helper and improve url names
* change check position
* Revert "change check position"
This reverts commit e4371d2f3aa8ad7ae5e5b7d15781b72a5f1be03c.
* repositioned central check
* add comment
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* wip
* add test
* readability
* remove group
* DisabledSync -> ConditionalSync; test both cases with dataset
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Add readied tenants
Add config for readied tenants
Add `create` and `clear` command
Add Readied scope and static functions
Add tests
* Fix initialize function name
* Add readied events
* Fix readied column cast
* Laravel 6 compatible
* Add readied scope tests
* Rename config from include_in_scope to include_in_queries
* Change terminology to pending
* Update CreatePendingTenants.php
* Laravel 6 compatible
* Update CreatePendingTenants.php
* runForMultiple can scope pending tenants
* Fix issues
* Code and comment style improvements
* Change 'tenant' to 'tenants' in command signature
* Fix code style (php-cs-fixer)
* Rename variables in CreatePendingTenants
* Remove withPending from runForMultiple
* Update tenants option trait
* Update command that use tenants
* Fix code style (php-cs-fixer)
* Improve getTenants condition
* Update config comments
* Minor config comment corrections
* Grammar fix
* Update comments and naming
* Correct comments
* Improve writing
* Remove pending tenant clearing time constraints
* Allow using only one time constraint for clearing the pending tenants
* phpunit to pest
* Fix code style (php-cs-fixer)
* Fix code style (php-cs-fixer)
* [4.x] Optionally delete storage after tenant deletion (#938)
* Add test for deleting storage after tenant deletion
* Save `storage_path()` in a variable after initializing tenant in test
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Add DeleteTenantStorage listener
* Update test name
* Remove storage deletion config key
* Remove tenant storage deletion events
* Move tenant storage deletion to the DeletingTenant event
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* [4.x] Finish incomplete and missing tests (#947)
* complete test sqlite manager customize path
* complete test seed command works
* complete uniqe exists test
* Update SingleDatabaseTenancyTest.php
* refactor the ternary into if condition
* custom path
* simplify if condition
* random dir name
* Update SingleDatabaseTenancyTest.php
* Update CommandsTest.php
* prefix random DB name with custom_
Co-authored-by: Samuel Štancl <samuel@archte.ch>
* [4.x] Add batch tenancy queue bootstrapper (#874)
* exclude master from CI
* Add batch tenancy queue bootstrapper
* add test case
* skip tests for old versions
* variable docblocks
* use Laravel's connection getter and setter
* convert test to pest
* bottom space
* singleton regis in TestCase
* Update src/Bootstrappers/BatchTenancyBootstrapper.php
Co-authored-by: Samuel Štancl <samuel@archte.ch>
* convert batch class resolution to property level
* enabled BatchTenancyBootstrapper by default
* typehint DatabaseBatchRepository
* refactore name
* DI DB manager
* typehint
* Update config.php
* use initialize() twice without end()ing tenancy to assert that previousConnection logic works correctly
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
* [4.x] Storage::url() support (modified #689) (#909)
* This adds support for tenancy aware Storage::url() method
* Trigger CI build
* Fixed Link command for Laravel v6, added StorageLink Events, more StorageLink tests, added RemoveStorageSymlinks Job, added Storage Jobs to TenancyServiceProvider stub, renamed misleading config example.
* Fix typo
* Fix code style (php-cs-fixer)
* Update config comments
* Format code in Link command, make writing more concise
* Change "symLinks" to "symlinks"
* Refactor Link command
* Fix test name typo
* Test fetching files using the public URL
* Extract Link command logic into actions
* Fix code style (php-cs-fixer)
* Check if closure is null in CreateStorageSymlinksAction
* Stop using command terminology in CreateStorageSymlinksAction
* Separate the Storage::url() test cases
* Update url_override comments
* Remove afterLink closures, add types, move actions, add usage explanation to the symlink trait
* Fix code style (php-cs-fixer)
* Update public storage URL test
* Fix issue with using str()
* Improve url_override comment, add todos
* add todo comment
* fix docblock style
* Add link command tests back
* Add types to $tenants in the action handle() methods
* Fix typo, update variable name formatting
* Add tests for the symlink actions
* Change possibleTenantSymlinks not to prefix the paths twice while tenancy is initialized
* Fix code style (php-cs-fixer)
* Stop testing storage directory existence in symlink test
* Don't specify full namespace for Tenant model annotation
* Don't specify full namespace in ActionTest
* Remove "change to DI" todo
* Remove possibleTenantSymlinks return annotation
* Remove symlink-related jobs, instantiate and use actions
* Revert "Remove symlink-related jobs, instantiate and use actions"
This reverts commit 547440c887.
* Add a comment line about the possible tenant symlinks
* Correct storagePath and publicPath variables
* Revert "Correct storagePath and publicPath variables"
This reverts commit e3aa8e2086.
* add a todo
Co-authored-by: Martin Vlcek <martin@dontfreakout.eu>
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
* Use HasTenantOptions in Link
* Correct the tenant order in Run command
* Fix code style (php-cs-fixer)
* Fix formatting issue
* Add missing imports
* Fix code style (php-cs-fixer)
* Use HasTenantOptions instead of the old trait name in Up/Down commands
* Fix test name typo
* Remove redundant passing of $withPending to runForMultiple in TenantCollection's runForEach
* Make `with-pending` default to `config('tenancy.pending.include_in_queries')` in HasTenantOptions
* Make `createPending()` return the created tenant
* Fix code style (php-cs-fixer)
* Remove tenant ordering
* Fix code style (php-cs-fixer)
* Remove duplicate tenancy bootstrappers config setting
* Add and use getWithPendingOption method
* Fix code style (php-cs-fixer)
* Add optionNotPassedValue property
* Test using --with-pending and the include_in_queries config value
* Make with-pending VALUE_NONE
* use plural in test names
* fix test names
* add pullPendingTenantFromPool
* Add docblock type
* Import commands
* Fix code style (php-cs-fixer)
* Move pending tenant tests to a more appropriate file
* Delete queuetest from gitignore
* Delete queuetest file
* Add queuetest to gitignore
* Rename pullPendingTenant to pullPending and don't pass bool to that method
* Add a test that checks if pulling a pending tenant removes it from the pool
* bump stancl/virtualcolumn to ^1.3
* Update pending tenant pulling test
* Dynamically get columns for pending queries
* Dynamically get virtual column name in ClearPendingTenants
* Fix ClearPendingTenants bug
* Make test name more accurate
* Update test name
* add a todo
* Update include in queries test name
* Remove `Tenant::query()->delete()` from pending tenant check test
* Rename the pending tenant check test name
* Update HasPending.php
* fix all() call
* code style
* all() -> get()
* Remove redundant `Tenant::all()` call
Co-authored-by: j.stein <joristein@gmail.com>
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>
Co-authored-by: Riley19280 <rileyaven88@gmail.com>
Co-authored-by: Martin Vlcek <martin@dontfreakout.eu>
* Add --schema-path to migration parameters config
* Set TenantDump's path to configured schema-path if the path doesn't get passed
* Test schema dump file creation and usage
* Fix code style (php-cs-fixer)
* hardcode default instead of reading from a config key that doesn't have to exist
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Add and test `Tenant::current()`
* Add and test `Tenant::currentOrFail()`
* Fix code style (php-cs-fixer)
* Update currentOrFail declaration
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Change self return type to static
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Add bring up from maintenance function
* Add up and down tenant maintenance commands
* Rename commands signatures
* Update TenancyServiceProvider.php
* Complying to Laravel maintenance code and parameters
* Update MaintenanceModeTest.php
* Add maintenance mode via commands test
* Update CheckTenantForMaintenanceMode.php
* Update MaintenanceModeTest.php
* Cookie bypass only for > Laravel 8
* minor formatting change, trigger CI
* clean
* Update MaintenanceModeTest.php
* Add comments for using the 'tenants' option in runForMultiple
* improve code
* php-cs-fixer
* fix php cs fixer config
* improve test logic
* remove version check since v4 will be L9+
Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* This adds support for tenancy aware Storage::url() method
* Trigger CI build
* Fixed Link command for Laravel v6, added StorageLink Events, more StorageLink tests, added RemoveStorageSymlinks Job, added Storage Jobs to TenancyServiceProvider stub, renamed misleading config example.
* Fix typo
* Fix code style (php-cs-fixer)
* Update config comments
* Format code in Link command, make writing more concise
* Change "symLinks" to "symlinks"
* Refactor Link command
* Fix test name typo
* Test fetching files using the public URL
* Extract Link command logic into actions
* Fix code style (php-cs-fixer)
* Check if closure is null in CreateStorageSymlinksAction
* Stop using command terminology in CreateStorageSymlinksAction
* Separate the Storage::url() test cases
* Update url_override comments
* Remove afterLink closures, add types, move actions, add usage explanation to the symlink trait
* Fix code style (php-cs-fixer)
* Update public storage URL test
* Fix issue with using str()
* Improve url_override comment, add todos
* add todo comment
* fix docblock style
* Add link command tests back
* Add types to $tenants in the action handle() methods
* Fix typo, update variable name formatting
* Add tests for the symlink actions
* Change possibleTenantSymlinks not to prefix the paths twice while tenancy is initialized
* Fix code style (php-cs-fixer)
* Stop testing storage directory existence in symlink test
* Don't specify full namespace for Tenant model annotation
* Don't specify full namespace in ActionTest
* Remove "change to DI" todo
* Remove possibleTenantSymlinks return annotation
* Remove symlink-related jobs, instantiate and use actions
* Revert "Remove symlink-related jobs, instantiate and use actions"
This reverts commit 547440c887.
* Add a comment line about the possible tenant symlinks
* Correct storagePath and publicPath variables
* Revert "Correct storagePath and publicPath variables"
This reverts commit e3aa8e2086.
* add a todo
Co-authored-by: Martin Vlcek <martin@dontfreakout.eu>
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
* exclude master from CI
* Add batch tenancy queue bootstrapper
* add test case
* skip tests for old versions
* variable docblocks
* use Laravel's connection getter and setter
* convert test to pest
* bottom space
* singleton regis in TestCase
* Update src/Bootstrappers/BatchTenancyBootstrapper.php
Co-authored-by: Samuel Štancl <samuel@archte.ch>
* convert batch class resolution to property level
* enabled BatchTenancyBootstrapper by default
* typehint DatabaseBatchRepository
* refactore name
* DI DB manager
* typehint
* Update config.php
* use initialize() twice without end()ing tenancy to assert that previousConnection logic works correctly
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
* complete test sqlite manager customize path
* complete test seed command works
* complete uniqe exists test
* Update SingleDatabaseTenancyTest.php
* refactor the ternary into if condition
* custom path
* simplify if condition
* random dir name
* Update SingleDatabaseTenancyTest.php
* Update CommandsTest.php
* prefix random DB name with custom_
Co-authored-by: Samuel Štancl <samuel@archte.ch>
* Add test for deleting storage after tenant deletion
* Save `storage_path()` in a variable after initializing tenant in test
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Add DeleteTenantStorage listener
* Update test name
* Remove storage deletion config key
* Remove tenant storage deletion events
* Move tenant storage deletion to the DeletingTenant event
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Throw an exception on attempt to create impersonation token with a non-stateful guard
* Test that impersonation tokens can only be created with a stateful guard
* Fix code style (php-cs-fixer)
* Escape backslashes in the exception's message
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Make the exception only about requiring a stateful guard
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* exclude master from CI
* Add space after 'up' in 'docker-compose up-d' (#900)
* Fix ArgumentCountError on the TenantAssetsController (#894)
* Fix ArgumentCount exception on the TenantAssetsController when no `$path` is provided
* CS
* CS
* Handle null case explicitly
* code style
Co-authored-by: Bram Wubs <bram@sibi.nl>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
* Add support for nested tenant config override (#920)
* feat: add support for nested tenant config override
* test: ensure nested tenant values are mapped
* Update TenantConfigTest.php
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: Bram Wubs <megawubs@users.noreply.github.com>
Co-authored-by: Bram Wubs <bram@sibi.nl>
Co-authored-by: George Bishop <email.georgebishop@gmail.com>
Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>