rezaamini-ir / laravel-tracker
Track your data in project
Requires
- php: >=7.2.5
- guzzlehttp/guzzle: ^7.2
- laravel/support: ^6.0|^7.0|^8.0|^9.0
Requires (Dev)
- orchestra/testbench: ~3.7|^4.0|^5.0|^6.0
This package is auto-updated.
Last update: 2024-10-29 00:31:53 UTC
README
A package to track your model data and monitor model data
Installation
First you should install package with composer :
composer require rezaamini-ir/laravel-tracker
Next publish dependencies :
php artisan tracker:install
Now you can run migration to create tracker tables:
php artisan migrate
There we go, We have installed package, Let's use it.
Usage
To use from package you must use from tracker trait in model which you want to track
use Tracker\Traits\Trackable; class Article extends Model{ use Trackable; }
Now you can use track()
method to track in your Article Single page controller
class ArticleContoller extends Controller { public function show(Article $article){ $article->track(); //.. } }
It will be tracked after every seen by users.
You can set track_mode
in config in choose what kind of tracker should be used in your project.
In your stats page you can use tracks()
and trackCount()
method to get tracked data.
For example :
class StatsContoller extends Controller { public function getStats(Article $article){ $article->trackCount(); // An integer of tracked count $article->tracks; // A collection of tracked data $article->trackBetween(now()->subDays(7), now()); // Tracked data between range of date since last week } }