postare / filament-contact-logs
接触日志
1.0.1
2024-03-13 14:36 UTC
Requires
- php: ^8.1
- filament/filament: ^3.0
- illuminate/contracts: ^10.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-09-13 15:39:36 UTC
README
Filament Contact Logs 是一个 Filament 3.x 插件,执行一个清晰且关键的功能:每次发送接触时都在日志中记录。无论接触的最终目的地如何,该插件都确保每个提交都详细跟踪。这使得操作员能够拥有所有接收到的通信的完整历史记录,提供了一个清晰且有序的互动和反馈图景。因此,其主要功能是确保接触的完全可追溯性,方便操作员进行管理和跟进。
安装
通过 composer 安装包
composer require postare/filament-contact-logs
发布并运行迁移
php artisan vendor:publish --tag="filament-contact-logs-migrations"
php artisan migrate
发布配置文件
php artisan vendor:publish --tag="filament-contact-logs-config"
已发布的配置文件内容
return [ /* * When the clean-command is executed, all recording activities older than * the number of days specified here will be deleted. */ 'delete_records_older_than_days' => 365, /* * Model to use to log activity. */ 'contact_log_model' => \Postare\FilamentContactLogs\Models\ContactLog::class, /* * List of Models associated with contact messages, it is not mandatory * to specify them, it is for obtaining a more user-friendly table. */ 'mappings' => [ // EXAMPLE: // 'App\Models\Property' => [ // 'type' => 'Property', // 'pluralType' => 'Properties', // 'label' => 'ID: {id}', // 'titleField' => 'name', // 'route' => 'property', // 'record_identifier' => 'slug', // ], ], ];
使用方法
与 Filament 面板集成
// app\Providers\Filament\AdminPanelProvider.php $panel ... ->plugins([ ... \Postare\FilamentContactLogs\FilamentContactLogsPlugin::make(), ]);
将模型与接触日志关联
// Use HasContactLogs trait in your model use Postare\FilamentContactLogs\Traits\HasContactLogs;
示例
将接触日志添加到模型
Property::find(1)->addContactLog([ 'content' => 'A beautiful message', 'subject' => 'A subject', 'sender_id' => auth()?->id(), // optional 'sender_email' => 'user@email.com', 'sender_name' => 'John Doe', 'sender_phone' => '1234567890', // optional ]);
添加不带模型的接触日志
contactLog([ 'content' => 'A beautiful message', 'subject' => 'A subject', 'sender_id' => auth()?->id(), // optional 'sender_email' => 'user@email.com', 'sender_name' => 'John Doe', 'sender_phone' => '1234567890', // optional ]);
自动删除日志
根据配置设置自动删除日志
// Add the following to your app\Console\Kernel.php protected function schedule(Schedule $schedule): void { $schedule->command('contact-logs:clean')->daily(); }
测试
composer test
变更日志
请参阅变更日志了解最近更改的更多信息。
贡献
请参阅贡献指南了解详细信息。
鸣谢
许可协议
MIT 许可协议 (MIT)。请参阅许可文件获取更多信息。