larva / laravel-censor
这是一个审查工具。
1.4.4
2022-07-28 07:59 UTC
Requires
- php: ^8.0
- illuminate/bus: ^8.0 || ^9.0
- illuminate/database: ^8.0 || ^9.0
- illuminate/events: ^8.0 || ^9.0
- illuminate/queue: ^8.0 || ^9.0
- illuminate/support: ^8.0 || ^9.0
- larva/laravel-settings: ^1.0
Requires (Dev)
Suggests
- larva/laravel-baidu-cloud: This is a baidu cloud expansion for the laravel.
- larva/laravel-tencent-cloud: This is a tencent cloud expansion for the laravel.
README
适用于 Laravel 的内容安全审查扩展。
环境需求
- PHP >= 7.4
安装
composer require larva/laravel-censor -vv
使用
自动审查
use Larva\Censor\Censor; $censor = Censor::make(); $content= '赚钱啦'; try { $content = $censor->textCensor($content); if($censor->isMod){ //需要审核 } } catch (CensorNotPassedException $e) { //有违禁词 }
表单验证
表单验证仅检查是否有违禁词,需要审查的直接是放行的,使用本扩展后,建议用户发布内容后,使用队列异步审查一遍。
$request->validate([ 'name' => ['required', 'string', new TextCensorRule], ]); $request->validate([ 'name' => ['required', 'string', 'text_censor'], ]);