Skip to content

Commit 6d9dd6a

Browse files
committed
Fix tenant scoped issue
1 parent 4d5433b commit 6d9dd6a

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/CustomFieldsServiceProvider.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,20 @@ public function bootingPackage()
3333
{
3434
$this->app->singleton(CustomsFieldsMigrators::class, CustomFieldsMigrator::class);
3535

36-
if (Utils::isTenantEnabled() && $tenantModel = Filament::getTenantModel()) {
37-
$tenantModelInstance = app($tenantModel);
38-
39-
CustomField::resolveRelationUsing('team', function (CustomField $customField) use ($tenantModel) {
40-
return $customField->belongsTo($tenantModel, config('custom-fields.column_names.tenant_foreign_key'));
41-
});
42-
43-
$tenantModelInstance->resolveRelationUsing('customFields', function (Model $tenantModel) {
44-
return $tenantModel->hasMany(CustomField::class, config('custom-fields.column_names.tenant_foreign_key'));
45-
});
36+
if(Utils::isTenantEnabled()) {
37+
foreach (Filament::getPanels() as $panel) {
38+
if ($tenantModel = $panel->getTenantModel()) {
39+
$tenantModelInstance = app($tenantModel);
40+
41+
CustomField::resolveRelationUsing('team', function (CustomField $customField) use ($tenantModel) {
42+
return $customField->belongsTo($tenantModel, config('custom-fields.column_names.tenant_foreign_key'));
43+
});
44+
45+
$tenantModelInstance->resolveRelationUsing('customFields', function (Model $tenantModel) {
46+
return $tenantModel->hasMany(CustomField::class, config('custom-fields.column_names.tenant_foreign_key'));
47+
});
48+
}
49+
}
4650
}
4751
}
4852

0 commit comments

Comments
 (0)