mirror of
https://github.com/archtechx/tenancy.git
synced 2026-03-22 07:54:04 +00:00
Laravel 13 support
- Update ci.yml and composer.json - Wrap single database tenancy trait scopes in whenBooted() - Update SessionSeparationTest to use laravel-cache- prefix in L13 and laravel_cache_ in <=L12. Our own prefix remains tenant_%tenant%_ (as configured in tenancy.cache.prefix). We could update this to be tenant-%tenant%- from now on for consistency with Laravel's prefixes (changed in https://github.com/laravel/framework/pull/56172) but I'm not sure yet. _ seems to read a bit better but perhaps consistency is more important. We may change this later and it can be adjusted in userland easily (since it's just a config option).
This commit is contained in:
parent
8f3ea6297f
commit
fd2696b405
5 changed files with 52 additions and 18 deletions
|
|
@ -12,6 +12,17 @@ trait BelongsToPrimaryModel
|
|||
abstract public function getRelationshipToPrimaryModel(): string;
|
||||
|
||||
public static function bootBelongsToPrimaryModel(): void
|
||||
{
|
||||
if (method_exists(static::class, 'whenBooted')) {
|
||||
// Laravel 13
|
||||
// For context see https://github.com/calebporzio/sushi/commit/62ff7f432cac736cb1da9f46d8f471cb78914b92
|
||||
static::whenBooted(fn () => static::configureBelongsToPrimaryModelScope());
|
||||
} else {
|
||||
static::configureBelongsToPrimaryModelScope();
|
||||
}
|
||||
}
|
||||
|
||||
protected static function configureBelongsToPrimaryModelScope()
|
||||
{
|
||||
$implicitRLS = config('tenancy.rls.manager') === TraitRLSManager::class && TraitRLSManager::$implicitRLS;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,17 @@ trait BelongsToTenant
|
|||
}
|
||||
|
||||
public static function bootBelongsToTenant(): void
|
||||
{
|
||||
if (method_exists(static::class, 'whenBooted')) {
|
||||
// Laravel 13
|
||||
// For context see https://github.com/calebporzio/sushi/commit/62ff7f432cac736cb1da9f46d8f471cb78914b92
|
||||
static::whenBooted(fn () => static::configureBelongsToTenantScope());
|
||||
} else {
|
||||
static::configureBelongsToTenantScope();
|
||||
}
|
||||
}
|
||||
|
||||
protected static function configureBelongsToTenantScope(): void
|
||||
{
|
||||
// If TraitRLSManager::$implicitRLS is true or this model implements RLSModel
|
||||
// Postgres RLS is used for scoping, so we don't enable the scope used with single-database tenancy.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue