PHP code example of devyousef / visitor

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

    

devyousef / visitor example snippets


'providers' => [

    Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
    Illuminate\Auth\AuthServiceProvider::class,
    ...
    Devyousef\Visitor\Providers\VisitorServiceProvider::class,

],



namespace App\Models;

use Devyousef\Visitor\Traits\Visitorable;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    use Visitorable;
    //
}

$post = Post::first();
$user = Auth::user();
$post->visit($user);

$postVisitor = Post::first()->visitorCount();
dd($postVisitor);
bash
php artisan vendor:publish --provider="Devyousef\Visitor\Providers\VisitorServiceProvider" --tag="migrations"
bash
php artisan migrate