Files
relaticle-comments/src/Filament/Actions/CommentsTableAction.php
manukminasyan f119095ae5 fix: use schema() instead of modalContent() for Filament 5 compatibility
Replace deprecated modalContent() with schema([CommentsEntry::make('comments')])
in both CommentsAction and CommentsTableAction to fix comment creation in
Filament 5 modals.
2026-03-27 17:48:32 +04:00

47 lines
1.2 KiB
PHP

<?php
namespace Relaticle\Comments\Filament\Actions;
use Filament\Actions\Action;
use Relaticle\Comments\Concerns\HasComments;
use Relaticle\Comments\Filament\Infolists\Components\CommentsEntry;
class CommentsTableAction extends Action
{
protected function setUp(): void
{
parent::setUp();
$this
->label(__('Comments'))
->icon('heroicon-o-chat-bubble-left-right')
->slideOver()
->modalHeading(__('Comments'))
->modalSubmitAction(false)
->modalCancelAction(false)
->schema([
CommentsEntry::make('comments'),
])
->badge(function (): ?int {
$record = $this->getRecord();
if (! $record) {
return null;
}
if (! in_array(HasComments::class, class_uses_recursive($record))) {
return null;
}
$count = $record->commentCount();
return $count > 0 ? $count : null;
});
}
public static function getDefaultName(): ?string
{
return 'comments';
}
}