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
ISSUE-38: Add pagination support for comments (#40)
* Add pagination support for comments
* Add test script to composer.json and update CommentsTest to throw TypeError
* Update perPageIncrement to correctly fallback to perPage
* Style Fix
Commentions supports built-in pagination for the embedded list of comments and it is enabled by default. You can disable it or control the number of comments shown per page and per click.
136
+
137
+
- Enabled by default
138
+
- Disable via `disablePagination()`
139
+
- Configure page size
140
+
- Customize the load more label
141
+
- Control how many comments are appended per click (defaults to the page size)
142
+
143
+
Examples:
144
+
145
+
Default Usage:
146
+
147
+
```php
148
+
use Kirschbaum\Commentions\Filament\Actions\CommentsAction;
149
+
150
+
->recordActions([
151
+
CommentsAction::make()
152
+
->mentionables(User::all())
153
+
->perPage(10)
154
+
155
+
])
156
+
```
157
+
Without Pagination:
158
+
159
+
```php
160
+
use Kirschbaum\Commentions\Filament\Actions\CommentsAction;
161
+
162
+
->recordActions([
163
+
CommentsAction::make()
164
+
->mentionables(User::all())
165
+
->disablePagination();
166
+
167
+
])
168
+
```
169
+
Advanced Usage:
170
+
171
+
```php
172
+
use Kirschbaum\Commentions\Filament\Infolists\Components\CommentsEntry;
173
+
174
+
Infolists\Components\Section::make('Comments')
175
+
->schema([
176
+
CommentsEntry::make('comments')
177
+
->mentionables(fn (Model $record) => User::all())
178
+
->perPage(8)
179
+
->loadMoreIncrementsBy(8)
180
+
->loadMoreLabel('Show older'),
181
+
])
182
+
```
183
+
184
+
When pagination is enabled, a "Show more" button is displayed to load additional comments incrementally.
185
+
133
186
#### Configuring the User model and the mentionables
134
187
135
188
If your `User` model lives in a different namespace than `App\Models\User`, you can configure it in `config/commentions.php`:
0 commit comments