miragepresent / likeable
Quick likes support
Installs: 18
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
pkg:composer/miragepresent/likeable
Requires
- php: >=7.0
This package is auto-updated.
Last update: 2025-11-29 02:36:29 UTC
README
Installation
Run composer require miragepresent/likeable;
And php artisan migrate
Usage
Just use Likeable trait in your model:
namespace App;
use Illuminate\Database\Eloquent\Model;
use MiragePresent\Likeable\Likeable;
class Photo extends Model {
use Likeable;
}
Now You are able to use methods like(), dislike() and toggleLike() in your model for adding/removing a like of an
authorized user.
Example:
/** @var \App\Photo $photo */
$photo = Photo::find(1);
// Add like to the photo
$photo->like();
var_dump($photo->is_liked); \\ true, 1
echo $photo->count_likes. ' user(s) liked this photo';
echo $photo->likedBy->ipmlode('name', ',') . ' liked this photo';