PHP code example of emilhorlyck / laravel-poly-metrics
1. Go to this page and download the library: Download emilhorlyck/laravel-poly-metrics library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
emilhorlyck / laravel-poly-metrics example snippets
// Modify metrics with daily and monthly resolution
PolyMetric::set('my-metric', 42); // This will set the metric to 42
PolyMetric::increment('my-metric'); // This will increment the metric by 1
PolyMetric::decrement('my-metric'); // This will decrement the metric by 1
// Modify metrics with only daily resolution
PolyMetric::setDaily('my-metric', 42); // This will set the metric to 42
PolyMetric::incrementDaily('my-metric'); // This will increment the metric by 1
PolyMetric::decrementDaily('my-metric'); // This will decrement the metric by 1
// Modify metrics with only monthly resolution
PolyMetric::setMonthly('my-metric', 42); // This will set the metric to 42
PolyMetric::incrementMonthly('my-metric'); // This will increment the metric by 1
PolyMetric::decrementMonthly('my-metric'); // This will decrement the metric by 1
use EmilHorlyck\PolyMetric\Traits\HasMetrics;
class User extends Model
{
use HasMetrics;
}
$user = User::find(1);
// Modify metrics with daily and monthly resolution
$user->setMetric('my-metric', 42); // This will set the metric to 42
$user->incrementMetric('my-metric'); // This will increment the metric by 1
$user->decrementMetric('my-metric'); // This will decrement the metric by 1
// Modify metrics with only daily resolution
$user->setDailyMetric('my-metric', 42); // This will set the metric to 42
$user->incrementDailyMetric('my-metric'); // This will increment the metric by 1
$user->decrementDailyMetric('my-metric'); // This will decrement the metric by 1
// Modify metrics with only monthly resolution
$user->setMonthlyMetric('my-metric', 42); // This will set the metric to 42
$user->incrementMonthlyMetric('my-metric'); // This will increment the metric by 1
$user->decrementMonthlyMetric('my-metric'); // This will decrement the metric by 1