Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/filament-comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
'empty' => 'heroicon-s-chat-bubble-left-right',
],


/*
* The comment model to be used
*/
'comment_model' => \Parallax\FilamentComments\Models\FilamentComment::class,

/*
* The policy that will be used to authorize actions against comments.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Actions/CommentsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ protected function setUp(): void
->modalWidth(MaxWidth::Medium)
->modalSubmitAction(false)
->modalCancelAction(false)
->visible(fn (): bool => auth()->user()->can('viewAny', FilamentComment::class));
->visible(fn (): bool => auth()->user()->can('viewAny', config('filament-comments.comment_model'));
}
}
2 changes: 1 addition & 1 deletion src/FilamentCommentsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function packageBooted(): void
{
Livewire::component('comments', CommentsComponent::class);

Gate::policy(FilamentComment::class, config('filament-comments.model_policy', FilamentCommentPolicy::class));
Gate::policy(config('filament-comments.comment_model'), config('filament-comments.model_policy', FilamentCommentPolicy::class));

FilamentAsset::register(
$this->getAssets(),
Expand Down
2 changes: 1 addition & 1 deletion src/Infolists/Components/CommentsEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ protected function setUp(): void
{
parent::setUp();

$this->visible(fn (): bool => auth()->user()->can('viewAny', FilamentComment::class));
$this->visible(fn (): bool => auth()->user()->can('viewAny', config('filament-comments.comment_model')));
}
}
4 changes: 2 additions & 2 deletions src/Livewire/CommentsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function mount(): void

public function form(Form $form): Form
{
if (!auth()->user()->can('create', FilamentComment::class)) {
if (!auth()->user()->can('create', config('filament-comments.comment_model'))) {
return $form;
}

Expand All @@ -45,7 +45,7 @@ public function form(Form $form): Form

public function create(): void
{
if (!auth()->user()->can('create', FilamentComment::class)) {
if (!auth()->user()->can('create', config('filament-comments.comment_model'))) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Models/Traits/HasFilamentComments.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait HasFilamentComments
public function filamentComments(): HasMany
{
return $this
->hasMany(FilamentComment::class, 'subject_id')
->hasMany(config('filament-comments.comment_model'), 'subject_id')
->where('subject_type', $this->getMorphClass())
->latest();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Tables/Actions/CommentsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ protected function setUp(): void
->modalWidth(MaxWidth::Medium)
->modalSubmitAction(false)
->modalCancelAction(false)
->visible(fn (): bool => auth()->user()->can('viewAny', FilamentComment::class));
->visible(fn (): bool => auth()->user()->can('viewAny', config('filament-comments.comment_model')));
}
}