luqta / viewcount
The package enables you to calculate the view count of a resource
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
The package enables you to calculate the view count of a resource (MongoDB Collection).
Installation
- Via Composer
$ composer require luqta/viewcount
- Validate
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',
- Add
view_count
field to your resource collection.
protected $fillable = [
...
'view_count',
...
];
- Dispatch
Luqta\ViewCount\ViewCountJob
job in your resource controller.
dispatch(new ViewCountJob($model, $request->validated()));
- Use
Luqta\ViewCount\Traits\Countable
trait in your resource model.