1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 22:14:03 +00:00
Commit graph

445 commits

Author SHA1 Message Date
Samuel Štancl
4af70d302f add extra $path validation to TenantAssetsController 2023-08-24 18:21:23 +02:00
Samuel Štancl
2d500f9780
Fix #1112 - throw an exception if DATABASE_URL is set (#9)
* fix #1112 - throw an exception when DATABASE_URL is defined, minor test changes

* Fix code style (php-cs-fixer)

* fix typo

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2023-08-18 20:21:00 +02:00
lukinovec
9d6356aea4
Close tenant connections after jobs (#1128)
* Test that the context is central after jobs get processed

* Revert to central context when jobs get processed, delete `$previousTenant` logic

* Test that the tenant connections get closed after jobs get processed

* Bring back the previous tenant logic

* Adapt tests to the previous tenant logic

* Delete assertion
2023-08-18 07:38:07 +02:00
lukinovec
af3812e788
Fix filesystem bootstrapper (#7)
* Test if Storage::url() works correctly after reverting to central context

* Fix typo in code

* Access originalPaths using dot notation using `data_get()`
2023-08-16 09:03:25 +02:00
lukinovec
948754cadc
Clone routes action improvements (#4)
* Use "clone" instead of "re-register" in UniversalRouteTest

* Fix `$shouldCloneRoute` condition, improve tenant flagging logic

* Use clone instead of reregister in stub
2023-08-07 18:32:13 +02:00
lukinovec
e3b59ae2b5
Improve file structure (#5)
* Add Enums and Overrides folders

* Fix code style (php-cs-fixer)

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2023-08-03 17:51:53 +02:00
Abrar Ahmad
1d0ca27bc8
Central routes without Route::domain(), configurable tenant/central routes by default for domain/subdomain identification, allow accessing central routes in early identification for path & request data middleware (#3)
* Update url binding bootstrapper test

* Fix parent::temporarySignedRoute() call

* Add universal route tests for all identification types

* Improve determineContextFromRequest()

* Add setting `TenancyUrlGenerator::$prefixRouteNames` to true in TSP stub

* Delete seemingly redundant test (making one route universal won't make all routes universal in any case)

* Use collection syntax in ReregisterUniversalRoutes

* Improve comments

* Add domain identification MW annotation

* Update condition in GloballyUsable

* Set `tenancy.bootstrappers` instead of adding the bootstrappers using `tenancy.bootstrappers.x`, move test

* Revert GloballyUsable condition change

* Delete assigning bootstrappers to tenancy.bootstrappers.x

* Exclude cache prefixing bootstrapper from the initial configuration

* Fix test

* Unset bypass parameter

* Set static kernel identification-related properties in TestCase

* Update bootstrapper name in annotation

* Move unset() into a condition

* Update TenancyUrlGenerator condition

* Set static properties without instantiating Tenancy

* Fix unsetting bypass parameter

* formatting changes

* add a comment

* improve docblock

* add docblock to TenancyUrlGenerator [ci skip]

* docblock changes [ci skip]

* Update TenancyUrlGenerator (rename variable, allow bypassing prefixing temporarySignedRoute name)

* Improve determineContextFromRequest

* Only return the new url generator instance when extending 'url' in UrlBindingBootstrapper

* Check route's MW groups for the path ID MW

* Remove extra imports from config

* Rename MiddlewareContext to Context, add condition for skipping ID MW

* Set only the needed bootstrappers in TestCase

* Fix code style (php-cs-fixer)

* Remove condition

* Use correct return type

* Fix PHPStan issue

* Update comment

* Check for tenant parameter instead of prefix

* Update shouldBeSkipped condition for universal routes

* Don't remove the 'universal' MW group after route re-registration, update test

* Fix code style (php-cs-fixer)

* Fix typo

* Add test for mixing placement of access prevention and identification MW

* Add test for mixing placement of access prevention and identification MW

* Update docblock

* Add setting the session and key resolvers in UrlBindingBootstrapper (required with LW file uploads)

* Update stub

* Update variable name in route reregistering action

* Add trailing comma

* Fix code style (php-cs-fixer)

* Require routes using path identification to be flagged as tenant in order to be recognized as tenant routes

* Add tenant flag while re-registering routes

* Update determineContextFromRequest condition (wip)

* Fix code style (php-cs-fixer)

* Update the middleware context logic so that universal routes have to be flagged as tenant instead of just having ID MW

* Update path identification condition

* Fix re-registering the LW localized route (add 'tenant' MW)

* Update docblock

* Simplify LW route re-registration

* Add comment

* Update comment

* Simplify determineContextFromRequest, add comment

* Improve stub

* Add skipRoute method + test

* Fix typo

* Update assets/TenancyServiceProvider.stub.php

* Update src/Concerns/DealsWithEarlyIdentification.php

* Fix typo

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* Improve comment

* Update test structure

* Restructure Fortify test

* code style

* Fix typo

* Update ReregisterUniversalRoutes annotation

* Only prefix route  name if it wasn't already prefixed

* Add todo@docs

* Delete `Tenancy::$kernelAccessPreventionSkipped` and related logic

* Delete test tenant cleanup

* Test MW group unpacking, restructure and improve test

* Test that tenancy isn't initialized after visiting a central route with the tenant parameter

* Delete "in both central and tenant contexts" from test names

* Test that re-registering works with controllers too

* Set misc route properties during re-registering

* Determine context instead of guessing, update universal route tests

* Use randomly generated tenant ID instead of hardcoding `acme`

* Remove setting route validators

* Rename and update determine context method, add comments

* Update ForgetTenantParameter annotation

* Add comment

* Delete comment, delete variable assignment

* Update early domain identification test

* Improve domain identification tests (test defaulting accurately)

* Improve readability

* Simplify domain early ID test

* Use randomly generated tenant instead of 'acme'

* Simplify request data ID test, use random tenant instead of 'acme'

* Simplify defaulting domain identification test

* Use RouteFacade alias for the Route facade, improve test code

* Add defaulting to the request data and path ID tests

* Merge path identification tenant parameter removal tests, clean up

* Correct wording

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* Delete debugging things from UniversalRouteTest

* Update annotation

* Add `// Creates a matrix`

* Improve comment wording

* Add MiddlewareUsableWithUniversalRoutes, refactor code accordingly

* Fix code style (php-cs-fixer)

* Delete debugging leftovers

* Delete unused import

* Update universal route GloballyUsable condition

* Don't implement the universal route interface in access prevention MW

* Check if request host is in the central domains in domain ID MW

* Test universal routes with domain identification without access prevent MW

* Test that universal routes work only with identification MW implementing the universal route interface

* Fix code style (php-cs-fixer)

* Rename GloballyUsable to UsableWithEarlyIdentification

* Fix annotation

* Update requestHasTenant annotations

* Update comment

* Add `with()` comments

* Add with() comments where missing

* Rename interface, update/add comments

* Rename exception, update its default message

* Fix code style (php-cs-fixer)

* Fix interface name

* Delete redundant code from subdomain ID MW

* Change domainOrSubdomain ID MW so that instead of passing the identification to other MWs, it happens in the domainOrSubdomain MW

* Test domainOrSubdomain identification with universal routes

* Fix code style (php-cs-fixer)

* Rename universal routes interface

* Fix code style (php-cs-fixer)

* Try explaining forgetting the tenant parameter better

* update interface name reference

* uncouple example from query parameters

* Update ForgetTenantParameter.php

* Update ForgetTenantParameter annotation

* Check both routeHasMiddleware and routeHasIdentificationMiddleware in the route MW detection test

* Hardcode tenant subdomain

* Delete redundant event listening code

* Delete unused imports

* Delete misuse of `tenancy()->getMiddlewareContext()` from conditions

* Delete unused variable

* Update comment

* Correct request data identification test (defaulting)

* Fix defaulting in path id test

* Move default route context configuration in domian id test

* Rename and update the tenant parameter test

* Delete extra tenant parameter test

* Use `tenant-domain.test` instead of `127.0.0.2`

* Add `default_to_universal_routes` config key

* Deal with defaulting to universal routes in the reregistering action

* Update logic to make defaulting to universal routes possible

* Test defaulting to universal routes

* Fix code style (php-cs-fixer)

* Delete extra tests

* Delete "without access prevention" from datasets

* Add defaulting to universal routes to datasets

* Override universal flag by central/tenant flag

* Add universal flag overriding test

* Update "a route can be universal in both route modes" so that the name corresponds with the tested thing

* Ignore the PHPStan error

* Reset `InitializeTenancyByPath::$onFail` in PathIdentificationTest

* Simplify expression

* Use 'Tenancy (not) initialized.' in instead of `tenant()?->getTenantKey()` for better assertions

* Properly test removing tenant parameter

* Reset static properties in tests

* Correct comments in EarlyIdentificationTest

* Add comment

* Add detail to annotation

* Throw exception if payload isn't string or null in request data ID MW

* Fix code style (php-cs-fixer)

* Delete static `$kernelIdentificationSkipped` property, use `$request->attributes` instead

* Use 'default_route_mode' instead of 'default_to_tenant/universal_routes'

* Fix code style (php-cs-fixer)

* Make path identification MW, tenantParameterName and tenantRouteNamePrefix configurable in ReregisterUniversalRoutes

* Delete unused import

* Add `$passTenantParameterToRoute` to TenancyUrlGenerator

* Use `$passTenantParameterToRoute` in BootstrapperTest

* Bypass tenant parameter passing

* Improve TenancyUrlGenerator so that both ID methods work

* Fix code style (php-cs-fixer)

* Improve TenancyUrlGenerator readability

* Add modifyBehavior() to TenancyUrlGenerator

* Fix code style (php-cs-fixer)

* Improve comment

* Toggle route name prefixing in path/request data ID MW (route-level identification)

* Fix code style (php-cs-fixer)

* Add path identification MW config key, add `getTenantParameterName()` to ForgetTenantParameter

* Fix code style (php-cs-fixer)

* Fix modifyBehavior and routeBehaviorModificationBypassed

* Add type to `$parameters` parameter

* Split modifyBehavior into two methods, don't pass name and parameters by reference

* Update UrlBindingBootstrapper annotation

* Correct naming in tests (request data -> query string identification)

* Add info to annotation

* Pass arrays to the behavior modification methods instead of `mixed`

* Fix default value of static property in Fortify bootstrapper

* Fix code style (php-cs-fixer)

* Correct annotation

* Enable prefixing routes directly using path identification MW

* Test re-registration of routes with path ID MW

* Prefix names of routes directly using path ID MW

* Fix code style (php-cs-fixer)

* Add Livewire v3 integration example to TSP stub

* Prefix route name only if it's not prefixed already

* Rename ReregisterUniversalRoutes to ReregisterRoutesAsTenant

* Fix code style (php-cs-fixer)

* Improve ReregisterRoutesAsTenant

* Add/update TenancyUrlGenerator docblocks

* Update action name in comments/test names

* Update reregister action annotation

* Delete unused imports

* Improve comments

* Make method protected

* Improve TenancyUrlGenerator code

* Test bypass parameter removal

* Fix comment

* Update annotation

* Improve shouldReregisterRoute

* Fix typo, delete redundant comment

* Improve skipRoute

* Improve shouldBeSkipped

* Add and test `$passTenantParameterToRoutes`

* add a comment

* Fix typo in comment

* Pass array as $parameters in prepareRouteInputs

* Make path_identification_middleware an array

* Fix code style (php-cs-fixer)

* Fix ReregisterRouteAsTenant

* Move tenantParameterName and tenantRouteNamePrefix getting to PathIdentificationManager

* Make PathIdentificationManager properties `Closure|null`

* Fix code style (php-cs-fixer)

* Fix PathIdentificationManager

* Update comments

* Use foreach for dataset definition

* Extract repetitive inGlobalStack and routeHasMiddleware calls

* Refactor PathIdentificationManager

* Update TenancyUrlGenerator annotation

* Add $skippedRoutes, refactor ReregisterRoutesAsTenant

* Improve reregisterRoute

* Update re-register action annotation

* update test name

* Make PathIdentificationManager methods static again, update comments

* Add test comment

* Update ForgetTenantParameter annotation

* Improve route re-registration condition, add comment

* Change "re-register" to "clone"

* minor code improvements

---------

Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2023-08-03 00:23:26 +02:00
Abrar Ahmad
bd9bbe8b41
Cache prefix mode for separating tenant caches (#1014)
* cache prefix

* prefix cache bootstrapper and tests

* remove comment

* DI app

* cache prefix base from config

* Create PrefixCacheBootstrapperTest.php

* remove `null` check

* fix phpstan error

* Update PrefixCacheTenancyBootstrapper.php

* Update PrefixCacheBootstrapperTest.php

* add comments

* Update PrefixCacheTenancyBootstrapper.php

* Update PrefixCacheBootstrapperTest.php

* Update config.php

* test names grammar

* user `getTenantKey` method

* assert tenants' data is accessible using the prefix from the central context

* remove unused line

* use proper DI

* build prefix using original prefix

* fix prefix test according to prefix changes

* fix test

* CacheManager dependency injection test

* CacheService class as singleton

* introduce second tenant in test

* use Repository in service class DI

* Update CacheAction.php

* Rename CacheAction to CacheService

* Update prefix bootstrapper and test (`setStore()` in CacheManager and Repository needed)

* Add macro

* Fix code style (php-cs-fixer)

* Simplify cache store refreshing

* Make Tenancy override CacheManager

* Update CacheManager, add refreshStore()

* Fix code style (php-cs-fixer)

* Uncomment cache tagging

* Revert condition in CacheManager to avoid excessive nesting

* Move `Cache::macro()` to a slightly more appropriate place

* Fix code style (php-cs-fixer)

* Use better class for the macro

* Toggle cache tags

* Make CacheManager::$addTags default to `true`

* Add changes to PR to Laravel

* Fix code style (php-cs-fixer)

* Revert changes, add comment

* Add test

* Make `$cache` non-nullable

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* Add and test `nonTenantCacheDrivers`

* Add nonTenantCacheDrivers check

* Test that the prefix stays the same

* Change nonTenantCacheDrivers to tenantCacheStores

* Remove redundant CacheManager extend() call

* Make 'redis' the only tenant cache store in beforeEach, test that tenantCacheStores works

* Remove unused import, change word

* Make CacheService a singleton in a test

* Update test name

* Remove group('prefix')

* Rename CacheManagerService

* Improve specific cache store in a service test

* Improve comment

* Improve tests

* Use my Laravel fork

* Fix code style (php-cs-fixer)

* Downgrade Laravel

* Upgrade Laravel

* Hint Repository implementation instead of contract

* Fix types

* Fix code style (php-cs-fixer)

* Fix test

* Use Laravel fork in ci.yml

* use dev-master before our changes are released in L10

* remove laravel fork from repositories

* use 10.x-dev instead of master

* remove L9 support

* 10.x-dev (fix conflict resolution)

* use the laravel version from the ci matrix for the phpstan job as well

* Revert "use the laravel version from the ci matrix for the phpstan job as well"

This reverts commit 5f3079d2ff.

* Test that non-default stores get prefixed too

* Use new Laravel release, remove L9 support

* Complete L9 support removal

* Specify 10.1.1 as the minimal Laravel version in ci.yml

* Use 10.x-dev

* Prefix all cache stores specified in `$tenantCacheStores`

* Update Laravel

* Use tmpfs in docker-compose

* Add customizing cache store prefixes

* Test cache prefixing customization

* Fix code style (php-cs-fixer)

* Update ci.yml

* Delete tmpfs from docker-compose.yml (there were no benefits)

* Use default prefix generator inline, delete the 'default' key logic

* Fix original prefix logic

* Update tests

* Delete CacheTenancyBootstrapper

* Reset static properties in afterEach

* Use `$this->config` instead of `config()`

* Disable cache tagging by default, add CacheTagBootstrapper

* Fix code style (php-cs-fixer)

* Rename bootstrapper

* Improve CacheManager

* Move logic from separate method to __call

* Make original prefixes customizable

* Add info in comment

* Add defaultPrefix property

* Use `$this->app` instead of `app()`

* Rename bootstrapper

* Fix code style (php-cs-fixer)

* Use a single original prefix

* Update prefix generator logic + tests

* Correct `$addTags` reset in a test

* Update cache tests so that both prefixing and tagging is covered

* Simplify cache tests

* Delete afterEach

* Small testing improvements

* Set `cache.default` in beforeEach

* Update cache prefixing and tests

* Add assertion

* Refactor assertion

* Refactor assertions

* Delete TTL from cache put calls

* Add re-initialization cache assertion

* Assert that cache is null from the beginning

* Merge the tenantCacheStores tests

* Fix formatting

* Improve test name

* Improve tests

* Add cache manager config key

* Fix code style (php-cs-fixer)

* Update defaulting test

* Add todo

* Update comments

* Extract duplicate assertions into a closure

* Update comment

* Add assertions + comment

* Delete redundant config put calls

* Use `tenancy.cache.manager` config instead of `Stancl\Tenancy\CacheManager`

* Change setting to assertion, add comment

* Inline variable & config key assignment

* Delete `cache.default` assertion

* Override cache manager only in CacheTagsBootstrapper

* Fix code style (php-cs-fixer)

* Prefix both drivers by default, add assertions for the second driver where missing

* Clean up global state (static properties) in before/afterEach

* Add docblock to tags bootstrapper

* Delete extra dependency

* Add `illuminate/support` dependency back

* Use `$addTags` approach again

* Fix code style (php-cs-fixer)

* Revert "Fix code style (php-cs-fixer)"

This reverts commit ea805fa231.

* Revert "Use `$addTags` approach again"

This reverts commit 8f5a4e4eb6.

* Add commented CacheTagsBootstrapper with info to the bootstrappers config

* Delete legacy bootstrapper from the bootstrappers config, add info to the bootstrapper's docblock

* Delete "?" from `tenant()?->getTenantKey()

* call generatePrefix() on $bootstrapper

* misc improvements

---------

Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-04-24 16:25:51 +02:00
lukinovec
e61a26d604
Add L10 support to 4.x (merge 3.x to master) (#1071)
* 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

* fix: typo mistake (#954)

* [3.x] Add Vite helper for tenancy (#956)

* Add Vite helper for tenancy

* Move Vite bundler to an Optional Feature

* Rename to foundation vite

* Add ViteBundlerTest

* Add missing end of file

* Update tests

* remove unnecessary end() call

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* rewrite ViteBundlerTest to phpunit syntax

* skip vite test in Laravel < 9

* convert ViteBundler to PHP 7 syntax

* remove import of nonexistent class in older Laravel versions

* remove import of Foundation\Vite in tests

* try to exclude Vite.php from coverage report

* remove typehint

* update channel name

* Cache crash fix (#1048)

* Don't prevent accessing missing Tenant attributes. (#1045)

* [3.x] L10 compatibility (#1065)

* Bump dependencies for Laravel 10

* Update GitHub Actions for Laravel 10

* ci: do not test L10 using PHP 7.3

* drop < L9 support

* use `dispatch_sync` instead of `dispatch_now`

* migrate phpunit configuration

* Update ci.yml

* drop laravel < 9 support

* misc L10 fixes, new docker image

* specify odbc version

* wip

* properly list php versions as strings

* minor changes

* Add `getValue($queryGrammar)` to raw query

* Clean up `isVersion8` code

* rewrite hasFailed assertion

* phpunit schema update

* Upgrade `doctrine/dbal`

---------

Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: lukinovec <lukinovec@gmail.com>

* Update ci.yml

* Fix code style (php-cs-fixer)

* Update dependencies

* Change invade version

* Delete ViteBundlerTest

* Fix PHPStan error

* Delete PHPStan error ignore

* Fix CONTRIBUTING.md

* Delete ViteBundler remains

* Bring back ViteBundler

* Convert ViteBundlerTest to Pest

* Update ci.yml

---------

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: Bram Wubs <megawubs@users.noreply.github.com>
Co-authored-by: Bram Wubs <bram@sibi.nl>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: George Bishop <email.georgebishop@gmail.com>
Co-authored-by: Anbuselvan Rocky <15264938+anburocky3@users.noreply.github.com>
Co-authored-by: Wilsen Hernández <13445515+wilsenhc@users.noreply.github.com>
Co-authored-by: Joel Stein <joel@mediatrix.digital>
Co-authored-by: Guilherme Saade <saade@outlook.com.br>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2023-02-20 23:47:10 +01:00
lukinovec
d7a4982cd3
[4.x] Make broadcasting work with Tenancy (#1027)
* Add BroadcastTenancyBootstrapper and TenancyBroadcastManager

* Fix code style (php-cs-fixer)

* Bind original BroadcastManager again on `revert()`

* Fix code style (php-cs-fixer)

* Move manager to correct directory

* Fix property type

* Make BroadcastTenancyBootstrapper a singleton in tests

* Fix code style (php-cs-fixer)

* Bind the original broadcaster instance on `revert()`

* Instead of just forgetting the old broadcaster instance, bind the new one

* Add BroadcastTenancyBootstrapper tests

* Separate the test

* Fix code style (php-cs-fixer)

* Add bootstrapper test

* Add broadcaster channels test

* Clean up BootstrapperTest

* Fix BroadcastingTest

* Add comments to TenancyBroadcastManager

* Add BroadcastTenancyBootstrapper comments

* Simplify BroadcastManager extension, remove setDriver method

* Add comment

* Fix PHPStan errors

* Fix PHPStan errors

* Remove duplicate import

* Fix test

* Delete `::class` from test name

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* Create databases for newly created tenants in BroadcastingTest

* move spatie/invade to require

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-02-18 15:52:55 +01:00
lukinovec
fbdb13f392
[4.x] Set app.url config in UrlTenancyBootstrapper (#1068)
* Set `app.url` config in UrlTenancyBootstrapper

* Add assertions

* Set base app URL in config

* Make UrlTenancyBootstrapper a singleton
2023-02-18 13:01:17 +01:00
lukinovec
617e9a7a73
[4.x] Allow user to customize tenant's URL root in CLI (#1044)
* Add UrlTenancyBootstrapper

* Fix code style (php-cs-fixer)

* Move URL overriding to a separate method, call it in `boot()`

* Test URL root overriding

* Change parameter formatting

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* Fix code style (php-cs-fixer)

* Improve URL bootstrapper test

* Move `$scheme` and `$hostname` to the closure

* Update code example comment

* Hardcode values instead of referencing variables

* Delete extra line

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-02-17 10:56:43 +01:00
Guilherme Saade
d4a99011e6
[3.x] L10 compatibility (#1065)
* Bump dependencies for Laravel 10

* Update GitHub Actions for Laravel 10

* ci: do not test L10 using PHP 7.3

* drop < L9 support

* use `dispatch_sync` instead of `dispatch_now`

* migrate phpunit configuration

* Update ci.yml

* drop laravel < 9 support

* misc L10 fixes, new docker image

* specify odbc version

* wip

* properly list php versions as strings

* minor changes

* Add `getValue($queryGrammar)` to raw query

* Clean up `isVersion8` code

* rewrite hasFailed assertion

* phpunit schema update

* Upgrade `doctrine/dbal`

---------

Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: lukinovec <lukinovec@gmail.com>
2023-02-16 17:21:06 +01:00
Abrar Ahmad
758fbc8a75
Use polymorphic table for mapping resources to tenants (#997)
* wip

* Fix code style (php-cs-fixer)

* adjust tests

* Update ResourceSyncingPolymorphicTest.php

* Update SyncMaster.php

* correct method name

* Update ResourceSyncingPolymorphicTest.php

* use BelongsToMany return type

* separate pivot model for each approach

* ability to publish migrations

* remove unsed import

* use resource migrations from asset

* anonymous migration for `tenant_resources` table

* rename file

* rename classes

* trait

* add back using statement

* revert to unset change

* use unset approach

* use unset approach

* Assert `tenants` are accessible

* Update ResourceSyncingUsingPolymorphicTest.php

* improve `tenants` assertions

* improve assertions

* remove `getResourceTenantModelName` method and use config

* use `BelongsToMany` for `tenants` method return type

* Fix code style (php-cs-fixer)

* revert type

* use correct key

* test right resources are accessible from the tenant

* Update tests/ResourceSyncingUsingPolymorphicTest.php

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2023-02-02 06:39:35 +01:00
Abrar Ahmad
087733d5db
Allow defining the tenant connection template using array syntax in config (#1040)
* `template_tenant_connection` can be array or string

* Update TenantDatabaseManagerTest.php

* Update TenantDatabaseManagerTest.php

* Update TenantDatabaseManagerTest.php

* Update DatabaseConfig.php

* partial database config for template

* Update tests/TenantDatabaseManagerTest.php

Co-authored-by: lukinovec <lukinovec@gmail.com>

* update test name

* improve test names

* add comments

---------

Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2023-02-01 07:02:03 +01:00
lukinovec
342c67fe02
Add skip-failing option to the Migrate command (#945)
* 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>
2023-02-01 06:55:26 +01:00
Samuel Štancl
c74a7b6fd4 remove debuggable trait, update larastan 2023-01-31 03:59:33 +01:00
Samuel Štancl
a0256fd5f3 Merge branch 'master' of github.com:archtechx/tenancy 2023-01-04 03:27:04 +01:00
Samuel Štancl
d0dd87ab07 bump PHP to 8.2, minor ci fixes 2023-01-04 02:43:10 +01:00
lukinovec
0f892f1585
Make tenants able to have custom mail credentials (#989)
* 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>
2023-01-04 02:12:25 +01:00
Abrar Ahmad
f42f08cb87
Add session state when impersonating tenant (#1029)
* wip

* Fix code style (php-cs-fixer)

* Update TenantUserImpersonationTest.php

* renamed method

* update method name in test

* rename session key

* fix test

* Update src/Features/UserImpersonation.php

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* Update UserImpersonation.php

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2022-12-17 02:08:03 +01:00
lukinovec
21dc69e358
Use invade in BootstrapperTest (#1033) 2022-12-15 15:03:03 +01:00
Samuel Štancl
b2dc0844eb Merge branch 'master' of github.com:tenancy-for-laravel/v4 2022-11-29 10:19:12 +01:00
lukinovec
7d3298c6bb
Improve code of pending tenants (#1025)
* Remove `--all` option from ClearPendingTenants

* Improve query formatting

* Remove redundant test

* Convert time constrait options to int

* Improve CreatePendingTenants success message
2022-11-29 09:31:07 +01:00
Abrar Ahmad
73c5655bc8
Manual mode improvements (use correct event type, add new listeners) (#1013)
* fix issue and add test

* Update CreateTenantConnection.php

* add purge call

* Update ManualModeTest.php

* use tenant connection and central connection listener

* Update ManualModeTest.php

* fix test

* improvements

* Update ManualModeTest.php

* add comment

* simplify comment

Co-authored-by: Samuel Štancl <samuel@archte.ch>
2022-11-25 03:09:31 +01:00
lukinovec
ea19117870
Use the hardcoded default path in TenantDump only if the path isn't configured (#1019)
* Use the hardcoded tenant dump path only if the path isn't configured

* Test generating tenant dump at the configured path
2022-11-23 13:12:29 +01:00
lukinovec
cb7567a88a
[4.x] Make TenantDump work when called outside the tenant context (#1015)
* Run TenantDump as passed tenant

* Fix code style (php-cs-fixer)

* Fix `tenants:dump` tests

* Update dump command test

* Remove redundant `tenant-schema.dump` unlinking

* Delete duplicate test

* Update test name

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2022-11-23 08:38:20 +01:00
Samuel Štancl
5849089373
Add SessionTenancyBootstrapper (#2)
* 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>
2022-11-20 02:32:25 +01:00
Abrar Ahmad
ff46bcfe20
Early identification support (#1)
* 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>
2022-11-20 02:31:37 +01:00
Samuel Štancl
8a00a105d0 Merge branch 'master' of github.com:archtechx/tenancy 2022-11-10 16:03:28 +01:00
Samuel Štancl
dd0f03f742 Fix #998, centralize config used by BelongsToTenant and HasDomains 2022-11-10 16:03:13 +01:00
Abrar Ahmad
ea3e44576f
[4.x] Resource syncing improvements (#992)
* Update TenantSyncingTest.php

* Update ResourceSyncingTest.php

* rename UserTenant to ResourceTenant

* Revert "rename UserTenant to ResourceTenant"

This reverts commit f9ba778e1b.

* rename TenantUser class

* return style

* Update ResourceSyncingTest.php

* revert return style

* Update ResourceSyncingTest.php
2022-11-09 13:00:54 +01:00
Abrar Ahmad
22d1b2065b
[4.x] Add feature to ignore the resource synchronization based on provided condition. (#993)
* wip

* add test

* readability

* remove group

* DisabledSync -> ConditionalSync; test both cases with dataset

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2022-11-04 15:04:29 +01:00
Abrar Ahmad
77c5ae1f32
[4.x] Configure attributes for synced resources when creating models (#915)
* configure attributes for creating resource

* Update ResourceSyncingTest.php

* Update ci.yml

* Update ResourceSyncingTest.php

* Update ci.yml

* cs

* comments

* Update tests/ResourceSyncingTest.php

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* improve comments, move method to `SyncMaster` interface

* Revert "improve comments, move method to `SyncMaster` interface"

This reverts commit 5ddd50deb9.

* Update ResourceSyncingTest.php

* Update ResourceSyncingTest.php

* update comment

* Update ResourceSyncingTest.php

* Update ResourceSyncingTest.php

* wip

* wip

* wip

* add a todo

* assert that creation attributes returns null

* classes at the end

* rename method to `getAttributesForCreation`

* Update ResourceSyncingTest.php

* update comments

* Fix little grammer

* merge default values with sync attributes and tests

* Update ResourceSyncingTest.php

* method rename

* method rename

* Update ResourceSyncingTest.php

* comments

* Update ResourceSyncingTest.php

* allow defining a mix of attribute names and default values

* add test

* code improvements

* Fix code style (php-cs-fixer)

* remove unused import

* fix all phpstan issues in resource syncing code

* Fix code style (php-cs-fixer)

* wip

* improve tests

* Update ResourceSyncingTest.php

* better names

* Update UpdateSyncedResource.php

* code style

* Update UpdateSyncedResource.php

* add comments above new tests

* methods dockblocks and correct names

* Update ResourceSyncingTest.php

* update comments

* remove different schema setup

* delete custom migrations

* self review

* grammar, code style

* refactor helpers for creating tenants

Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2022-11-03 17:51:29 +01:00
Samuel Štancl
198f34f5e1
[4.x] Add pending tenants (modified #782) (#869)
* 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>
2022-10-31 12:14:44 +01:00
Abrar Ahmad
bf504f4c79
[4.x] Use a dedicated DB connection for creating/deleting tenant databases (#946)
* create host connection for creating, deleting tenants

* purge connection and add more tests

* remove unused method

* Improvements

* test named

* remove host connection name config key

* Revert "remove host connection name config key"

This reverts commit 42acb823e8.

* Update DatabaseConfig.php

* Update assets/config.php

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* Update DatabaseConfig.php

* todo and comments

* remove debug code

* Update DatabaseConfig.php

* strict assertions

* Update TenantDatabaseManagerTest.php

* Update src/Database/DatabaseConfig.php

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* purge connection improvements

* Update DatabaseConfig.php

* Update DatabaseConfig.php

* Update DatabaseConfig.php

* improve comments

* remove "ensuring connection exists" check

* remove test because it's duplicate

* removing test because other two tests are using the same logic, so this test kinda already covered

* Update TenantDatabaseManagerTest.php

* Update DatabaseConfig.php

* Revert "Update TenantDatabaseManagerTest.php"

This reverts commit b8e0a1c982.

* add default

* Update src/Database/DatabaseConfig.php

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* update comment

* remove unness mysql config and add a comment

* tenancy_db_connection tenant config test

* Update TenantDatabaseManagerTest.php

* update test name and improve assertions

* typo

* change inline variable name

* Update TenantDatabaseManagerTest.php

* Update TenantDatabaseManagerTest.php

* add DB::purge() calls

* add new assertions [ci skip]

* Fix code style (php-cs-fixer)

* replace hostManager with manager

* fix test

* method rename

Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2022-10-31 12:13:54 +01:00
lukinovec
15dc40839b
Unlink tenant schema path before each test in CommandsTest (#986)
* Add tenantSchemaPath method

* Unlink tenant schema path before each test in CommandsTest

* Remove the tenantSchemaPath helper
2022-10-26 12:08:14 +02:00
lukinovec
a1a976c863
[4.x] Make tenants:migrate default to configured schema path (#985)
* 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>
2022-10-25 18:03:04 +02:00
Samuel Štancl
fe0a322b87 add public connection() method to the Tenant DB manager interface 2022-10-25 12:53:31 +02:00
Jori Stein
e4f5b92485
[4.x] Update commands CLI outputs (#968)
* Using laravel components

* Ensure commands returns success

* update tests

* clean

* bump EndBug version

* Update ci.yml

* Update ci.yml

* Update ci.yml

* revert CI changes

* Update ci.yml

* Update ci.yml

* Update ci.yml

* revert CI changes to it's original state

* fix typos, improve code

* improve Install & TenantList commands

* php-cs-fixer

* type GitHub properly

Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2022-10-18 19:11:57 +02:00
Abrar Ahmad
05f1b2d6f5
Add cookie option on Initialize Tenancy by Request identification (#980)
* Add cookie option on Initialize Tenancy by Request identification

* add cookie property
2022-10-18 13:52:16 +02:00
Jori Stein
3f60c4a652
Add maintenance mode events (#979) 2022-10-17 19:48:24 +02:00
lukinovec
080b271bb3
[4.x] Drop tenant databases on migrate:fresh (#971)
* Test that `migrate:fresh` deletes tenant databases

* Delete tenants on `migrate:fresh`

* Fix code style (php-cs-fixer)

* Add config key for dropping tenant databases on `migrate:fresh`

* Add MigrateFreshOverride

* Try to override `migrate:fresh` in TenancyServiceProvider

* Update `migrate:fresh` test

* Fix code style (php-cs-fixer)

* Drop tenant databases by default

* Change `migrate:fresh` test to test if the tenant DBs are dropped by default

* Override `migrate:fresh` by extending `FreshCommand` in TenancyServiceProvider

* Update MigrateFreshOverride

* Fix code style (php-cs-fixer)

* Fix commands test

* Simplify handle method

* Fix code style (php-cs-fixer)

* Don't drop tenant DBs on migrate:fresh by default

* Change command overriding

* Update migrate:fresh test

* always register MigrateFreshOverride

* misc

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2022-10-17 15:19:30 +02:00
lukinovec
42dab2985a
Add current() and currentOrFail() tenant methods (#970)
* 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>
2022-10-11 10:33:32 +02:00
Samuel Štancl
ccaba05272 Add identification section to config, refactor static properties 2022-10-01 20:01:18 +02:00
Samuel Štancl
24146b26e2 fix #854 2022-10-01 17:59:33 +02:00
Samuel Štancl
f98a901aeb get down to 21 phpstan errors 2022-09-29 23:39:35 +02:00
Samuel Štancl
a94227a19c get down to 59 phpstan errors 2022-09-29 22:20:55 +02:00
Samuel Štancl
193e044777 remove remaining version checks 2022-09-29 16:02:40 +02:00
Samuel Štancl
fa09e3a083 remove version checks 2022-09-29 16:02:08 +02:00