You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- The three separate traits (HasFavoriteForumPost, HasMentionables, HasForumUserSearch) have been consolidated into a single `ForumUser` trait. Users should update their User model to use `ForumUser` instead of the three separate traits.
Copy file name to clipboardExpand all lines: README.md
+39-40Lines changed: 39 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,29 +80,25 @@ A forum package for Filament apps that provides both admin and frontend resource
80
80
81
81
- Ensure your User model has a `name` attribute
82
82
83
-
- Add `HasFavoriteForumPost` trait to your `User` model:
83
+
- Add the `ForumUser` trait to your `User` model:
84
84
85
85
```php
86
-
use Tapp\FilamentForum\Models\Traits\HasFavoriteForumPost;
86
+
use Tapp\FilamentForum\Traits\ForumUser;
87
87
88
88
class User extends Authenticatable
89
89
{
90
90
// ...
91
-
use HasFavoriteForumPost;
91
+
use ForumUser;
92
92
// ...
93
93
}
94
94
```
95
95
96
-
- Add `HasMentionables` trait (you can use it to customize which users are mentionable, see below in "Custom Mentionables") to your `User` model
97
-
98
-
```php
99
-
use Tapp\FilamentForum\Models\Traits\HasMentionables;
100
-
101
-
class User extends Authenticatable
102
-
{
103
-
use HasMentionables;
104
-
}
105
-
```
96
+
The `ForumUser` trait provides:
97
+
-`forums()` relationship - Get all forums the user is assigned to
98
+
-`favoriteForumPosts()` relationship - Get all favorite forum posts
99
+
-`getMentionableUsers()` method - Customize which users are mentionable (see "Custom Mentionables" below)
100
+
-`hasCustomForumSearch()`, `getForumSearchResults()`, `getForumOptionLabel()` methods - Custom search functionality (see "Custom User Model, Attribute, and Search Functionality" below)
101
+
-`isForumAdmin()` method - Override to grant admin access to hidden forums (defaults to `false`)
106
102
107
103
6. Add to your custom theme (usually`theme.css`) file:
108
104
@@ -301,33 +297,11 @@ For more detailed information about implementing multi-tenancy in Filament, see
301
297
302
298
## Custom User Model, Attribute, and Search Functionality
303
299
304
-
By default, the `name` column of `User` model is used for the `user` relationship. You can customize it using the `title-attribute` on `filament-form.php` config file.
300
+
By default, the `name` column of `User` model is used for the `user` relationship. You can customize it using the `title-attribute` on `filament-forum.php` config file.
305
301
306
302
The Filament Forum plugin also supports custom search functionality for user selects in forms and filters. This allows you to customize which users' columns are used to search and display in dropdowns (eg. if your `User` model doesn't have a `name` column).
307
303
308
-
## Setup
309
-
310
-
### 1. Add the Trait to Your User Model
311
-
312
-
Add the `HasForumUserSearch` trait to your User model:
313
-
314
-
```php
315
-
<?php
316
-
317
-
namespace App\Models;
318
-
319
-
use Illuminate\Foundation\Auth\User as Authenticatable;
320
-
use Tapp\FilamentForum\Traits\HasForumUserSearch;
321
-
322
-
class User extends Authenticatable
323
-
{
324
-
use HasForumUserSearch;
325
-
326
-
// Your existing model code...
327
-
}
328
-
```
329
-
330
-
### 2. Configure Your User Model Class
304
+
### Configure Your User Model Class
331
305
332
306
Make sure your `config/filament-forum.php` file points to the correct `User` model:
333
307
@@ -338,7 +312,7 @@ Make sure your `config/filament-forum.php` file points to the correct `User` mod
338
312
],
339
313
```
340
314
341
-
### 3. Customize the Search Methods
315
+
### Customize the Search Methods
342
316
343
317
Override the trait methods in your User model to customize search behavior:
344
318
@@ -348,11 +322,11 @@ Override the trait methods in your User model to customize search behavior:
348
322
namespace App\Models;
349
323
350
324
use Illuminate\Foundation\Auth\User as Authenticatable;
351
-
use Tapp\FilamentForum\Traits\HasForumUserSearch;
325
+
use Tapp\FilamentForum\Traits\ForumUser;
352
326
353
327
class User extends Authenticatable
354
328
{
355
-
use HasForumUserSearch;
329
+
use ForumUser;
356
330
357
331
/**
358
332
* Custom search that searches both name and email
@@ -392,6 +366,31 @@ public static function getMentionableUsers()
392
366
}
393
367
```
394
368
369
+
## Forum Access Control
370
+
371
+
Forums can be set as public (visible to all logged-in users) or hidden (only visible to assigned users). Forum admins can see all hidden forums regardless of assignment.
372
+
373
+
### Setting Forum Access
374
+
375
+
In the admin panel, you can set a forum as hidden by checking the "Hidden Forum" checkbox. Hidden forums will only be visible to:
376
+
- Users who are explicitly assigned to the forum
377
+
- Forum admins (users where `isForumAdmin()` returns `true`)
378
+
379
+
### Forum Admin Access
380
+
381
+
Override the `isForumAdmin()` method in your User model to grant admin access:
0 commit comments