mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 04:04:04 +00:00
Resolver refactor, path identification improvements (#41)
* resolver refactor * Fix code style (php-cs-fixer) * make tenant column used in PathTenantResolver configurable, fix phpstan errors, minor improvements * support binding route fields, write tests for customizable tenant columns * Invalidate cache for all possible columns in path resolver * implement proper cache separation logic for different columns used by PathTenantResolver * improve return type --------- Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
This commit is contained in:
parent
dc430666ba
commit
0c11f29c19
17 changed files with 370 additions and 88 deletions
|
|
@ -137,10 +137,10 @@ class Tenancy
|
|||
/**
|
||||
* Try to find a tenant using an ID.
|
||||
*/
|
||||
public static function find(int|string $id): Tenant|null
|
||||
public static function find(int|string $id, string $column = null): (Tenant&Model)|null
|
||||
{
|
||||
/** @var (Tenant&Model)|null */
|
||||
$tenant = static::model()->where(static::model()->getTenantKeyName(), $id)->first();
|
||||
/** @var (Tenant&Model)|null $tenant */
|
||||
$tenant = static::model()->firstWhere($column ?? static::model()->getTenantKeyName(), $id);
|
||||
|
||||
return $tenant;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue