@@ -31,6 +31,14 @@ This is the contents of the published config file:
3131
3232``` php
3333return [
34+ /*
35+ | Help Article Model
36+ |
37+ | If you extend the HelpArticle model, specify your extended model here.
38+ | This ensures Filament resources use your extended model.
39+ */
40+ 'model' => env('FILAMENT_HELP_MODEL', \Tapp\FilamentHelp\Models\HelpArticle::class),
41+
3442 'tenancy' => [
3543 // Enable or disable tenancy features globally
3644 'enabled' => env('FILAMENT_HELP_TENANCY_ENABLED', false),
@@ -225,21 +233,76 @@ Or use environment variables in your `.env` file:
225233
226234``` env
227235FILAMENT_HELP_TENANCY_ENABLED=true
236+ FILAMENT_HELP_TENANCY_MODEL=App\Models\Team
228237FILAMENT_HELP_TENANCY_COLUMN=team_id
238+ FILAMENT_HELP_TENANCY_RELATIONSHIP=team
229239FILAMENT_HELP_TENANCY_SCOPE_ADMIN=true
230240FILAMENT_HELP_TENANCY_SCOPE_FRONTEND=true
231241FILAMENT_HELP_TENANCY_SCOPE_GUEST=false
232242```
233243
234- 2 . ** Run migrations** :
244+ 2 . ** Add the tenant relationship to your HelpArticle model** :
245+
246+ Since the package needs to support various tenant models (Team, Organization, etc.), you need to define the relationship in your application.
247+
248+ Extend the ` HelpArticle ` model in your application:
249+
250+ ``` php
251+ // app/Models/HelpArticle.php
252+ namespace App\Models;
253+
254+ use Illuminate\Database\Eloquent\Relations\BelongsTo;
255+ use Tapp\FilamentHelp\Models\HelpArticle as BaseHelpArticle;
256+
257+ class HelpArticle extends BaseHelpArticle
258+ {
259+ /**
260+ * Get the team that owns the help article.
261+ */
262+ public function team(): BelongsTo
263+ {
264+ return $this->belongsTo(\App\Models\Team::class);
265+ }
266+ }
267+ ```
268+
269+ Or if you use a different tenant model:
270+
271+ ``` php
272+ public function organization(): BelongsTo
273+ {
274+ return $this->belongsTo(\App\Models\Organization::class);
275+ }
276+ ```
277+
278+ ** Important** : Make sure the relationship name matches the ` relationship ` config value you set (e.g., ` 'team' ` or ` 'organization' ` ).
279+
280+ Then, update your config to use your extended model:
281+
282+ ``` php
283+ // config/filament-help.php
284+ return [
285+ 'model' => \App\Models\HelpArticle::class,
286+
287+ 'tenancy' => [
288+ 'enabled' => true,
289+ 'model' => \App\Models\Team::class,
290+ 'column' => 'team_id',
291+ 'relationship' => 'team',
292+ // ...
293+ ],
294+ ];
295+ ```
296+
297+ 3 . ** Run migrations** :
235298
236299When tenancy is enabled, the migration will automatically add the tenant column to the ` help_articles ` table:
237300
238301``` bash
239302php artisan migrate
240303```
241304
242- 3 . ** Configure your Filament panel with tenancy** :
305+ 4 . ** Configure your Filament panel with tenancy** :
243306
244307``` php
245308// In your AdminPanelProvider.php (or wherever you configure your Filament panel)
0 commit comments