1. Go to this page and download the library: Download filamerce/filament-comments library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
filamerce / filament-comments example snippets
namespace App\Models;
use Filamerce\FilamentComments\Models\Traits\HasFilamentComments;
class Product extends Model
{
use HasFilamentComments;
}
namespace App\Filament\Resources\ProductResource\Pages;
use Filamerce\FilamentComments\Actions\CommentsAction;
class ViewProduct extends ViewRecord
{
protected function getHeaderActions(): array
{
return [
CommentsAction::make(),
];
}
}
namespace App\Filament\Resources;
use Filamerce\FilamentComments\Tables\Actions\CommentsAction;
class ProductResource extends Resource
{
public static function table(Table $table): Table
{
return $table
->actions([
CommentsAction::make(),
]);
}
}
namespace App\Filament\Resources;
use Filamerce\FilamentComments\Infolists\Components\CommentsEntry;
class ProductResource extends Resource
{
public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
CommentsEntry::make('filament_comments'),
]);
}
}
use Filamerce\FilamentComments\Support\CommentSanitizer;
use Symfony\Component\HtmlSanitizer\HtmlSanitizerConfig;
$this->app->singleton(CommentSanitizer::class, fn () => new CommentSanitizer(
CommentSanitizer::defaultConfig()->allowAttribute('style', allowedElements: '*'),
));
namespace App\Console;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Filamerce\FilamentComments\Models\FilamentComment;
class Kernel extends ConsoleKernel
{
protected function schedule(Schedule $schedule)
{
$schedule->command('model:prune', [
'--model' => [FilamentComment::class],
])->daily();
// This will not work, as models in a package are not used by default
// $schedule->command('model:prune')->daily();
}
}