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
Page
Model in a extra package/plugin. My tenant Model is
Project
Project
.
To add the tenancy awarenes I 1. add the foreignId project_id to the pages migration 2. add HasMany pages() to the
Project
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?