Skip to content

Latest commit

 

History

History
80 lines (54 loc) · 1.31 KB

4_quick-start.md

File metadata and controls

80 lines (54 loc) · 1.31 KB

Quick Start

Start using it

It's simple.

Using visits helper as:

visits($model)->{method}()

Where:

  • $model: is any Eloquent model from your project.
  • {method}: any method that is supported by this library, and they are documented below.

Tags

  • You can track multiple kinds of visits to a single model using the tags as
visits($model,'tag1')->increment();

Integration with any model

You can add a visits method to your model class:

class Post extends Model
{

    //....

    public function vzt()
    {
        return visits($this);
    }
}

Then you can use it as:

$post = Post::find(1);
$post->vzt()->increment();
$post->vzt()->count();

Relationship with models (only for Eloquent engine)

If you are using visits with eloquent as engine (from config/visits.php; engine => \Awssat\Visits\DataEngines\EloquentEngine::class) then you can add a relationship method to your models.

class Post extends Model
{

    //....

    public function visits()
    {
        return visits($this)->relation();
    }
}

//then:

Post::with('visits')->get();

Prev: < Installation

Next: Increments and decrements >