Skip to content

Commit

Permalink
Make methods non-static in DealsWithModels
Browse files Browse the repository at this point in the history
  • Loading branch information
lukinovec committed Jan 25, 2024
1 parent 2cd2dd4 commit 692860e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Database/Concerns/DealsWithModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ trait DealsWithModels
/**
* Discover all models in the directories configured in 'tenancy.rls.model_directories'.
*/
public static function getModels(): array
public function getModels(): array
{
if (static::$modelDiscoveryOverride) {
return (static::$modelDiscoveryOverride)();
Expand Down Expand Up @@ -49,17 +49,17 @@ public static function getModels(): array
/**
* Filter all models retrieved by static::getModels() to get only the models that belong to tenants.
*/
public static function getTenantModels(): array
public function getTenantModels(): array
{
return array_filter(static::getModels(), fn (Model $model) => static::modelBelongsToTenant($model) || static::modelBelongsToTenantIndirectly($model));
return array_filter($this->getModels(), fn (Model $model) => $this->modelBelongsToTenant($model) || $this->modelBelongsToTenantIndirectly($model));
}

public static function modelBelongsToTenant(Model $model): bool
public function modelBelongsToTenant(Model $model): bool
{
return in_array(BelongsToTenant::class, class_uses_recursive($model::class));
}

public static function modelBelongsToTenantIndirectly(Model $model): bool
public function modelBelongsToTenantIndirectly(Model $model): bool
{
return in_array(BelongsToPrimaryModel::class, class_uses_recursive($model::class));
}
Expand Down

0 comments on commit 692860e

Please sign in to comment.