Skip to content

Commit

Permalink
Merge pull request shetabit#8 from cyrildewit/feature/captilize-sente…
Browse files Browse the repository at this point in the history
…nces

Capitalize sentences in readme
  • Loading branch information
khanzadimahdi authored Mar 13, 2020
2 parents eda6d54 + 285f8de commit 0a08835
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<p align="center"><img width="200" src="resources/images/visitor.png?raw=true"></p>




# Laravel Visitor

this is a laravel package to extract and access visitors' information such as `browser`, `ip`, `device` and etc.
This is a laravel package to extract and access visitors' information such as `browser`, `ip`, `device` and etc.

**in this package, you can recognize online users and determine if a user is online or not**
**In this package, you can recognize online users and determine if a user is online or not**

### Install

via composer
Via composer

```bash
composer require shetabit/visitor
Expand All @@ -35,7 +32,7 @@ If you are using Laravel 5.5 or higher then you don't need to add the provider a
],
```

then, run the below commands to publish migrations and create tables
Then, run the below commands to publish migrations and create tables

```bash
php artisan vendor:publish
Expand All @@ -45,9 +42,9 @@ php artisan migrate

### How to use

you can access to `visitor's information` using `$request->visitor()` in your controllers , and you can access to the visitor's information using `visitor()` helper function any where.
You can access to `visitor's information` using `$request->visitor()` in your controllers , and you can access to the visitor's information using `visitor()` helper function any where.

we have the below methods to retrieve a visitor's information:
We have the below methods to retrieve a visitor's information:

- `device` : device's name
- `platform` : platform's name
Expand All @@ -66,7 +63,7 @@ $request->visitor()->setVisitor($user)->visit($post); // create a log wich says

#### Store Logs

you can create logs using the `visit` method like the below
You can create logs using the `visit` method like the below

```php
visitor()->visit(); // create a visit log
Expand All @@ -87,8 +84,9 @@ visitor()->setVisitor($user)->visit($model);

```

model views can be loaded using `visits` relation.
you can count model visits like the below
Model views can be loaded using `visits` relation.

You can count model visits like the below

```php
$model->visitLogs()->count();
Expand All @@ -105,7 +103,7 @@ $user->visit($model); // create a log which says, $user has visited $model

use `Shetabit\Visitor\Traits\Visitor` in your `User` class at first.

then you can retrieve online users which are instance of `User` class and determine if a user is online.
Then you can retrieve online users which are instance of `User` class and determine if a user is online.

```php
visitor()->onlineVisitors(User::class); // returns collection of online users
Expand All @@ -117,8 +115,8 @@ $user->isOnline(); // another way

#### Automatic logging

your application can store visitor's log automatically using `LogVisits` middleware.
Your application can store visitor's log automatically using `LogVisits` middleware.

add the `Shetabit\Visitor\Middlewares\LogVisits` middleware if you want to save logs automatically.
Add the `Shetabit\Visitor\Middlewares\LogVisits` middleware if you want to save logs automatically.

the middleware will store logs for models which has binded in router (router model binding) and has used `Shetabit\Visitor\Traits\Visitable` trait.
The middleware will store logs for models which has binded in router (router model binding) and has used `Shetabit\Visitor\Traits\Visitable` trait.

0 comments on commit 0a08835

Please sign in to comment.