PHP code example of panoscape / tracker

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

    

panoscape / tracker example snippets


'providers' => [
    ...
    Panoscape\Tracker\TrackerServiceProvider::class,
];



namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Panoscape\Tracker\Context;

class Project extends Model
{
    use Context;

    public function getContextLabel()
    {
        return $this->display_name;
    }

    ...
}

$project->records();

$project->records;

use Context { records as logs; }



namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\SoftDeletes;
use Panoscape\Tracker\Agent;

class User extends Authenticatable
{
    use SoftDeletes, Notifiable, Agent;

    ...
}

$user->records();

$user->records;

use Agent { records as logs; }

$record->context();

$record->context;

$record->hasAgent();

$record->agent();

$record->agent;

$record->meta;

[
    ['key' => 'name', 'old' => 'myName', 'new' => 'myNewName'],
    ['key' => 'age', 'old' => 10, 'new' => 100],
    ...
]



return [

    /*
    |--------------------------------------------------------------------------
    | Tracker Language Lines
    |--------------------------------------------------------------------------
    |
    | The following language lines are used across application for various
    | messages that we need to display to the user. You are free to modify
    | these language lines according to your application's 



return [

    /*
    |--------------------------------------------------------------------------
    | Tracker Language Lines
    |--------------------------------------------------------------------------
    |
    | The following language lines are used across application for various
    | messages that we need to display to the user. You are free to modify
    | these language lines according to your application's 



return [

    ...

    'project' => '项目',
    'component_template' => '组件模板',
];



return [

    /*
    |--------------------------------------------------------------
    | Literally
    |--------------------------------------------------------------
    |
    |
    */
    'enabled' => true,

    /*
    |--------------------------------------------------------------
    | Record table name
    |--------------------------------------------------------------
    |
    |
    */
    'records_table' => 'tracker_records',

    /*
    |--------------------------------------------------------------
    | Operatiopn whitelist
    |--------------------------------------------------------------
    |
    | Operations in this array will be recorded.
    | Available operations are: created, updating, deleting, restored
    |
    */
    'operations' => [
        'created', 'updating', 'deleting', 'restored',
    ],

    /*
    |--------------------------------------------------------------
    | Agent blacklist
    |--------------------------------------------------------------
    |
    | Operations performed by agents in this array will NOT be recorded.
    | Please add the whole class names. Example: \App\User
    | Use 'nobody' to bypass unauthenticated operations
    |
    */
    'agent_ignore' => [
        
    ],

    /*
    |--------------------------------------------------------------
    | Enabled when application running in console
    |--------------------------------------------------------------
    |
    | When application is running in console(
shell
php artisan vendor:publish --provider="Panoscape\Tracker\TrackerServiceProvider" --tag=config
shell
php artisan vendor:publish --provider="Panoscape\Tracker\TrackerServiceProvider" --tag=migrations
php artisan migrate
shell
php artisan vendor:publish --provider="Panoscape\Tracker\TrackerServiceProvider" --tag=translations