2017 © Pedro Peláez
 

package lara-like

Add Likeable trait to Laravel Eloquent models

image

inpin/lara-like

Add Likeable trait to Laravel Eloquent models

  • Tuesday, June 5, 2018
  • by enourinick
  • Repository
  • 1 Watchers
  • 5 Stars
  • 109 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 276 % Grown

The README.md

LaraLike

Important note: this product is forked and edited from base laravel-likeable package., (*1)

Build Status StyleCI Maintainability Latest Stable Version Total Downloads Latest Unstable Version License, (*2)

Trait for Laravel Eloquent models to allow easy implementation of a "like" or "favorite" or "remember" or what ever you want features., (*3)

Composer Install (for Laravel 5.5 and above)

composer require inpin/lara-like

Install and then run the migrations

'providers' => [
    \Inpin\LaraLike\LaraLikeServiceProvider::class,
],
php artisan vendor:publish --provider="Inpin\LaraLike\LaraLikeServiceProvider" --tag=migrations
php artisan migrate

Setup your models

class Book extends \Illuminate\Database\Eloquent\Model {
    use Inpin\LaraLike\Likeable;
}

Sample Usage

$book->like(); // like the book for current user
$book->like($user); // pass in your own user
$book->like(0); // just add likes to the count, and don't track by user
$book->like('api'); // like the book for current user with guard 'api'
$book->like(null, 'bookmark') // add book for current user to bookmarks
$book->like($user, 'bookmark') // pass user and type

$book->unlike(); // remove like from the book
$book->unlike($user); // pass in your own user id
$book->unlike(0); // remove likes from the count -- does not check for user
$book->unlike('api'); // remove like from book for current user with guard 'api'
$book->unlike(null, 'bookmark') // remove current book from current user bookmarks
$book->unlike($user, 'bookmark') // pass user and type

$book->likes; // Iterable Illuminate\Database\Eloquent\Collection of existing likes 
$book->likes()->where('type', 'bookmark')

$book->liked(); // check if currently logged in user liked the book
$book->liked($myUserId);

$book->likeCount($type); // determine number of likes for given $type (default type is 'like')

Article::whereLikedBy($myUserId) // find only books where user liked them
    ->with('likeCounter') // highly suggested to allow eager load
    ->get();

note: default type is 'like'., (*4)

Credits

  • Mohammad Nourinik - http://inpinapp.com

The Versions

05/06 2018

dev-master

9999999-dev

Add Likeable trait to Laravel Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mohammad Nourinik

laravel eloquent trait laravel5 remember like follow favorite likeable likable favourite

05/06 2018

1.0.4

1.0.4.0

Add Likeable trait to Laravel Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mohammad Nourinik

laravel eloquent trait laravel5 remember like follow favorite likeable likable favourite

02/06 2018

1.0.3

1.0.3.0

Add Likeable trait to Laravel Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mohammad Nourinik

laravel eloquent trait laravel5 remember like follow favorite likeable likable favourite

24/10 2017

1.0.2

1.0.2.0

Add Likeable trait to Laravel Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mohammad Nourinik

laravel eloquent trait laravel5 remember like follow favorite likeable likable favourite

23/10 2017

v1.0.1

1.0.1.0

Add Likeable trait to Laravel Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mohammad Nourinik

laravel eloquent trait laravel5 remember like follow favorite likeable likable favourite

18/10 2017

v1.0.0

1.0.0.0

Add Likeable trait to Laravel Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mohammad Nourinik

laravel eloquent trait laravel5 remember like follow favorite likeable likable favourite

18/10 2017

1.0.0

1.0.0.0

Add Likeable trait to Laravel Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mohammad Nourinik

laravel eloquent trait laravel5 remember like follow favorite likeable likable favourite