https://filamentphp.com/plugins/coolsam-nested-comments
1.composer 経由でパッケージをインストールします。
composer require coolsam/nested-comments
2.artisanコマンドでnested-commentインストールします。
php artisan nested-comments:install
3.blogモテルに commentを追加します。
use Coolsam\NestedComments\Concerns\HasReactions;ーー>ここ追加
class Blog extends Model
{
use HasComments;ーー>ここ追加
protected $fillable = [
'title',
'status',
'image',
'detail',
];
}
4.blogのinfolistにコメントを追加します。
public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
Section::make()
->schema([
TextEntry::make('name')
->prose()
->markdown()
TextEntry::make('detail')
->prose()
->markdown()
]),
\Coolsam\NestedComments\Filament\Infolists\CommentsEntry::make('comments'),ーー>ここ追加
]);
}
追加
reactionを追加したりカスタマイズもできます。
nested-commentsインストールする際にconfigフォルダの中にnested-comments.php作成されるので、
そのファイルに様々なカスタマイズできます。
いいねボタンを追加してみます。
'allowed-reactions' => [
'👍' => 'thumbs up', // thumbs up
'👎' => 'thumbs down', // thumbs down
'❤️' => 'heart', // heart
'😂' => 'laughing', // laughing
'😮' => 'surprised', // surprised
'😢' => 'crying', // crying
'💯' => 'hundred points', // angry
'🔥' => 'fire', // fire
'🎉' => 'party popper', // party popper
'🚀' => 'rocket', // rocket
'いいね!' => 'iine', // iine いいね!テキストを追加
]