luqta / viewcount
该包使您能够计算资源的查看次数
v2.0
2020-02-16 12:15 UTC
Requires
- ext-mongodb: *
- illuminate/support: ~5|~6
- jenssegers/mongodb: ^3.6
Requires (Dev)
- mockery/mockery: ^1.1
- orchestra/testbench: ~3|~4
- phpunit/phpunit: ^8.0
- sempro/phpunit-pretty-print: ^1.0
README
该包使您能够计算资源(MongoDB 集合)的查看次数
安装
- 通过 Composer
$ composer require luqta/viewcount
- 验证
vistor_ip
'user_id' => 'string',
'countable' => 'required|boolean',
'vistor_ip' => 'required_if:countable,1|string',
'user_agent' => 'required_if:countable,1|string',
'browser_language' => 'required_if:countable,1|string',
'screen.width' => 'required_if:countable,1|numeric',
'screen.height' => 'required_if:countable,1|numeric',
'inner.width' => 'required_if:countable,1|numeric',
'inner.height' => 'required_if:countable,1|numeric',
- 将
view_count
字段添加到您的资源集合中。
protected $fillable = [
...
'view_count',
...
];
- 在您的资源控制器中调度
Luqta\ViewCount\ViewCountJob
任务。
dispatch(new ViewCountJob($model, $request->validated()));
- 在您的资源模型中使用
Luqta\ViewCount\Traits\Countable
特性。