PHP code example of mzaman / trails

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

    

mzaman / trails example snippets


php artisan vendor:publish --provider="MasudZaman\Trails\TrailsServiceProvider"

/**
 * The application's global HTTP middleware stack.
 *
 * These middleware are run during every request to your application.
 *
 * @var array
 */
protected $middleware = [
    \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
    \App\Http\Middleware\EncryptCookies::class,
    \MasudZaman\Trails\Middleware\CaptureAttributionDataMiddleware::class, // <-- Add
];

namespace App\Models;

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use MasudZaman\Trails\TrackableInterface;
use MasudZaman\Trails\TrackRegistrationAttribution;

class User extends Model implements TrackableInterface // <-- Add
{
    use Authenticatable;
    use TrackRegistrationAttribution; // <-- Add 

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'users';
}

'connection_name' => 'mytrackingdbconnection'

'model' => 'App\Models\User'

'guard' => 'web'

'model_column_name' => 'user_id'

'attribution_duration' => 2628000

'landing_page_blacklist' => ['genealabs/laravel-caffeine/drip', 'admin']

'cookie_domain' => .yourdomain.com

'async' => true

'uniqueness' => false

$user = User::find(1);
$user->visits;

$user = User::find(1);
$user->initialAttributionData();

$user = User::find(1);
$user->finalAttributionData();

$schedule->command('trails:prune')->daily();

$schedule->command('trails:prune --days=10')->daily();

'disable_robots_tracking' => true