mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 18:54:03 +00:00
Move RLS toggling and model directories config to tenancy.rls
This commit is contained in:
parent
6b19a26d2c
commit
f859a5da06
4 changed files with 14 additions and 15 deletions
|
|
@ -21,9 +21,9 @@ trait BelongsToTenant
|
|||
|
||||
public static function bootBelongsToTenant(): void
|
||||
{
|
||||
// If tenancy.database.rls is true or this model implements RlsModel
|
||||
// If tenancy.rls.enabled is true or this model implements RlsModel
|
||||
// Scope queries using Postgres RLS instead of TenantScope
|
||||
if (! (config('tenancy.database.rls') || (new static) instanceof RLSModel)) {
|
||||
if (! (config('tenancy.rls.enabled') || (new static) instanceof RLSModel)) {
|
||||
static::addGlobalScope(new TenantScope);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ use Symfony\Component\Finder\SplFileInfo;
|
|||
|
||||
trait DealsWithModels
|
||||
{
|
||||
public static array $modelDirectories = ['App/Models'];
|
||||
|
||||
public static Closure|null $modelDiscoveryOverride = null;
|
||||
|
||||
public static function getModels(): Collection
|
||||
|
|
@ -22,7 +20,7 @@ trait DealsWithModels
|
|||
return (static::$modelDiscoveryOverride)();
|
||||
}
|
||||
|
||||
$modelFiles = Finder::create()->files()->name('*.php')->in(static::$modelDirectories);
|
||||
$modelFiles = Finder::create()->files()->name('*.php')->in(config('tenancy.rls.model_directories'));
|
||||
|
||||
$classes = collect($modelFiles)->map(function (SplFileInfo $file) {
|
||||
$fileContents = str($file->getContents());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue