larva / laravel-censor
This is a censor.
Installs: 1 603
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 0
Open Issues: 0
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'], ]);