PHP code example of arrtrust / tracker

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

    

arrtrust / tracker example snippets


    'providers' => array(
    
        'Illuminate\Foundation\Providers\ArtisanServiceProvider',
        'Illuminate\Auth\AuthServiceProvider',
        ...
        'Arrtrust\Tracker\TrackerServiceProvider',
    
    ),
    

   'aliases' => array(
   
       'App'        => 'Illuminate\Support\Facades\App',
       'Artisan'    => 'Illuminate\Support\Facades\Artisan',
       ...
       'Tracker'   => 'Arrtrust\Tracker\TrackerFacade'
   
   ),
   

    tracker()->getCurrent();
    Tracker::saveCurrent();
    
    tracker()->isViewUnique();
    tracker()->isViewValid();
    
    tracker()->addTrackable($post);
    
    Tracker::flushAll();
    Tracker::flushOlderThan(Carbon::now());
    Tracker::flushOlderThenOrBetween(Carbon::now(), Carbon::now()->subYear());
    

    protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'guard' => \App\Http\Middleware\Guard::class,
        'track' => \Arrtrust\Tracker\TrackerMiddleware::class
    ];
    

        
        use Illuminate\Database\Eloquent\Model as Eloquent;
        use Arrtrust\Tracker\Trackable;
        use Arrtrust\Tracker\TrackableInterface;
        
        class Node extends Eloquent implements TrackableInterface {
            
            use Trackable;
            
        }
    

        
        
        use Illuminate\Database\Schema\Blueprint;
        use Illuminate\Database\Migrations\Migration;
        
        class CreateNodeSiteViewPivotTable extends Migration {
        
            /**
             * Run the migrations.
             *
             * @return void
             */
            public function up()
            {
                Schema::create('node_site_view', function (Blueprint $table)
                {
                    $table->integer('node_id')->unsigned();
                    $table->integer('site_view_id')->unsigned();
        
                    $table->foreign('node_id')
                        ->references('id')
                        ->on('nodes')
                        ->onDelete('cascade');
        
                    $table->foreign('site_view_id')
                        ->references('id')
                        ->on('site_views')
                        ->onDelete('cascade');
        
                    $table->primary(['node_id', 'site_view_id']);
                });
            }
        
            /**
             * Reverse the migrations.
             *
             * @return void
             */
            public function down()
            {
                Schema::drop('node_site_view');
            }
        }

    
bash
    php artisan vendor:publish