Tenancy with other packages Model

I have a existing filament project used across multiple projects. So I'm trying to add tenancy functionality now to manage all projects within one instance. I have some CMS functionality with a Page Model in a extra package/plugin. My tenant Model is Project. To add the tenancy awarenes I 1. add the foreignId project_id to the pages migration 2. add HasMany pages() to the Project Model 3. add the relation with the following from a ProjectRelationServiceProvider.php
Page::resolveRelationUsing('project', function ($model) {
return $model->belongsTo(Project::class, 'project_id');
});
Page::resolveRelationUsing('project', function ($model) {
return $model->belongsTo(Project::class, 'project_id');
});
Is this the right approach to add tenancy awarenes to a Model coming from another package?
1 Reply
mmoollllee
mmoolllleeOP2w ago
And how is tenancy used with other plugins like filament-logger? https://github.com/Z3d0X/filament-logger
GitHub
GitHub - Z3d0X/filament-logger: Extensible activity logger for fila...
Extensible activity logger for filament that works out-of-the-box. - Z3d0X/filament-logger

Did you find this page helpful?