1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-04 22:34:05 +00:00

Make methods non-static in DealsWithModels

This commit is contained in:
lukinovec 2024-01-25 14:36:11 +01:00
parent 2cd2dd4b5f
commit 692860eb6f

View file

@ -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)();
@ -49,17 +49,17 @@ trait DealsWithModels
/**
* 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));
}