PHP code example of lulzshadowwalker / laravel-metrics

1. Go to this page and download the library: Download lulzshadowwalker/laravel-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/ */

    

lulzshadowwalker / laravel-metrics example snippets


use Metrics\Traits\HasMetrics;

class Tenant extends Model
{
    use HasMetrics;
}

enum Metric: string
{
    case SignedUp = 'signed_up';
    case OrderPlaced = 'order_placed';
    case HumanEscalated = 'human_escalated';
}

$tenant->record(Metric::OrderPlaced, ['channel' => 'web']);

// meta is optional
$tenant->record(Metric::HumanEscalated);

$tenant->metrics()->type(Metric::OrderPlaced)->today()->count();

$tenant->metrics()
    ->type(Metric::HumanEscalated)
    ->period(now()->subDays(30), now())
    ->count();

namespace App\Models;

use Metrics\Models\Event as BaseEvent;

class Event extends BaseEvent
{
    //
}

return [
    'model' => \App\Models\Event::class,
];
shell
php artisan vendor:publish --tag=metrics-migrations
php artisan vendor:publish --tag=metrics-config
php artisan migrate