2017 © Pedro Peláez
 

library view-counter

A view and like counter extension for your laravel project.

image

fraank/view-counter

A view and like counter extension for your laravel project.

  • Wednesday, November 11, 2015
  • by fraank
  • Repository
  • 2 Watchers
  • 16 Stars
  • 486 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 4 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Laravel ViewCounter

A view and like counter extension for your laravel project. It uses session storage if the user is not logged in and keeps it clean while the session is active (no double likes or views). If a user is logged in, the information about hthe likes and views are stored into the database for getting history., (*1)

Installation

Install using composer:, (*2)

composer require fraank/view-counter

While the package is not stable, please make sure you added it as dev: Open "composer.json" manually and add "fraank/view-counter": "dev-master" into require., (*3)

Add the service provider in app/config/app.php:, (*4)

Fraank\ViewCounter\ViewCounterServiceProvider::class,

The service provider will register an interface for your models to use view_counter and like_couter functionality., (*5)

To create the basic tables you have to provide the migation files:, (*6)

php artisan vendor:publish

Now you can migrate:, (*7)

php artisan migrate

Now you can register the like and view functionality in your model:, (*8)

class Object extends Eloquent {
  use Fraank\ViewCounter\ViewCounterTrait;
}

You can call the actions for like and unlike in your views (or controllers) like this:, (*9)

{{ route('view_counter.like', array('class_name' => 'post', 'object_id' => $post->id)) }}
{{ route('view_counter.unlike', array('class_name' => 'post', 'object_id' => $post->id)) }}

Examples

Basic Usage

**Increment a ViewCounter in a Controller (show action), (*10)

$object->view();

**Get count of Views, (*11)

$object->views_count();

**Did the user viewed the object?, (*12)

$object->isViewed();

**Increment the LikeCounter in a Controller (show action), (*13)

$object->like();

**Unlike, (*14)

$object->unlike();

**Get count of Likes, (*15)

$object->likes_count();

**Did the user liked the object?, (*16)

$object->isLiked();

The Versions

11/11 2015

dev-master

9999999-dev https://github.com/fraank/ViewCounter

A view and like counter extension for your laravel project.

  Sources   Download

MIT

The Requires

 

by Frank Cieslik

counter views likes

17/02 2015

4.x-dev

4.9999999.9999999.9999999-dev

  Sources   Download

The Requires

 

by Frank Cieslik