laravel-like maintained by zing
Last update
2026/03/18 17:28
License
Require
- php ^8.0
- laravel-interaction/support ^1.0 || ^2.0 || ^3.0
- illuminate/database ^8.13 || ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0
- illuminate/support ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0
Last update
2026/03/18 17:28
License
Require
- php ^8.0
- illuminate/database ^8.13 || ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0
- illuminate/support ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0
- laravel-interaction/support ^1.0 || ^2.0 || ^3.0
Last update
2025/02/24 16:46
License
Require
- php ^8.0
- illuminate/database ^8.13 || ^9.0 || ^10.0 || ^11.0 || ^12.0
- illuminate/support ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0
- laravel-interaction/support ^1.0 || ^2.0 || ^3.0
Last update
2024/03/18 15:48
License
Require
- php ^8.0
- illuminate/database ^8.13 || ^9.0 || ^10.0 || ^11.0
- illuminate/support ^8.0 || ^9.0 || ^10.0 || ^11.0
- laravel-interaction/support ^1.0 || ^2.0 || ^3.0
Last update
2023/08/19 03:20
License
Require
- php ^8.0
- illuminate/database ^8.13 || ^9.0 || ^10.0
- illuminate/support ^8.0 || ^9.0 || ^10.0
- laravel-interaction/support ^1.0 || ^2.0 || ^3.0
Last update
2023/03/17 15:00
License
Require
- php ^8.0
- illuminate/database ^8.13 || ^9.0 || ^10.0
- illuminate/support ^8.0 || ^9.0 || ^10.0
- laravel-interaction/support ^1.0 || ^2.0 || ^3.0
Last update
2023/01/29 18:19
License
Require
- php ^8.0
- illuminate/database ^8.13 || ^9.0 || ^10.0
- illuminate/support ^8.0 || ^9.0 || ^10.0
- laravel-interaction/support ^1.0 || ^2.0
Last update
2022/11/27 14:49
License
Require
- php ^8.0
- illuminate/database ^8.13 || ^9.0
- illuminate/support ^8.0 || ^9.0
- laravel-interaction/support ^1.0 || ^2.0
Last update
2022/08/16 14:35
License
Require
- php ^7.3 || ^8.0
- illuminate/database ^8.13 || ^9.0
- illuminate/support ^8.0 || ^9.0
- laravel-interaction/support ^1.0 || ^2.0
Last update
2022/08/16 14:35
License
Require
- php ^7.3 || ^8.0
- illuminate/database ^8.13 || ^9.0
- illuminate/support ^8.0 || ^9.0
- laravel-interaction/support ^1.0 || ^2.0
Last update
2022/03/18 10:02
License
Require
- php ^7.3 || ^8.0
- illuminate/database ^8.13 || ^9.0
- illuminate/support ^8.0 || ^9.0
- laravel-interaction/support ^1.0 || ^2.0
Last update
2022/03/10 10:11
License
Require
- php ^7.3 || ^8.0
- illuminate/database ^8.13 || ^9.0
- illuminate/support ^8.0 || ^9.0
- laravel-interaction/support ^1.0 || ^2.0
Last update
2022/02/21 13:07
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0 || ^9.0
- illuminate/support ^6.0 || ^7.0 || ^8.0 || ^9.0
- laravel-interaction/support ^1.0
Last update
2022/02/21 13:07
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0 || ^9.0
- illuminate/support ^6.0 || ^7.0 || ^8.0 || ^9.0
- laravel-interaction/support ^1.0
Last update
2022/01/13 13:10
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0 || ^9.0
- illuminate/support ^6.0 || ^7.0 || ^8.0 || ^9.0
- laravel-interaction/support ^1.0
Last update
2022/01/13 13:10
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0 || ^9.0
- illuminate/support ^6.0 || ^7.0 || ^8.0 || ^9.0
- laravel-interaction/support ^1.0
Last update
2022/01/01 10:18
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
- laravel-interaction/support ^1.0
Last update
2021/11/10 04:36
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
- laravel-interaction/support ^1.0
Last update
2021/10/15 13:48
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
- laravel-interaction/support ^1.0
Last update
2021/09/02 13:50
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
- laravel-interaction/support ^1.0
Last update
2021/09/02 13:50
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
- laravel-interaction/support ^1.0
Last update
2021/08/31 12:36
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
- laravel-interaction/support ^1.0
Last update
2021/08/28 05:44
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
- laravel-interaction/support ^0.6
Last update
2021/08/28 05:44
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
- laravel-interaction/support ^0.6
Last update
2021/08/25 12:14
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
- laravel-interaction/support ^0.6
Last update
2021/05/01 17:21
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
- laravel-interaction/support ^0.4
Last update
2021/04/30 13:16
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
- laravel-interaction/support ^0.4
Last update
2021/03/17 12:07
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
- laravel-interaction/support ^0.3
Last update
2021/03/16 12:10
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
- laravel-interaction/support ^0.3
Last update
2021/03/12 08:56
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
- laravel-interaction/support ^0.1.0
Last update
2021/03/01 09:29
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.3 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
- laravel-interaction/support ^0.1.0
Last update
2021/02/13 03:00
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.20.12 || ^7.30.3 || ^8.22.1
- illuminate/support ^6.0 || ^7.0 || ^8.0
Last update
2021/01/04 16:04
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.0 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
Last update
2020/11/22 15:38
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.0 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
Last update
2020/11/22 13:39
License
Require
- php ^7.2 || ^8.0
- illuminate/database ^6.0 || ^7.0 || ^8.0
- illuminate/support ^6.0 || ^7.0 || ^8.0
Laravel Like
User like/unlike behaviour for Laravel.
Introduction
It let people express how they feel about the model(documentation/subject/topic).
Installation
Requirements
Instructions
Require Laravel Like using Composer.
composer require laravel-interaction/like
Publish configuration and migrations
php artisan vendor:publish --tag=like-config
php artisan vendor:publish --tag=like-migrations
Run database migrations.
php artisan migrate
Usage
Setup Fan
use Illuminate\Database\Eloquent\Model;
use LaravelInteraction\Like\Concerns\Fan;
class User extends Model
{
use Fan;
}
Setup Likeable
use Illuminate\Database\Eloquent\Model;
use LaravelInteraction\Like\Concerns\Likeable;
class Channel extends Model
{
use Likeable;
}
Fan
use LaravelInteraction\Like\Tests\Models\Channel;
/** @var \LaravelInteraction\Like\Tests\Models\User $user */
/** @var \LaravelInteraction\Like\Tests\Models\Channel $channel */
// Like to Likeable
$user->like($channel);
$user->unlike($channel);
$user->toggleLike($channel);
// Compare Likeable
$user->hasLiked($channel);
$user->hasNotLiked($channel);
// Get liked info
$user->fanLikes()->count();
// with type
$user->fanLikes()->withType(Channel::class)->count();
// get liked channels
Channel::query()->whereLikedBy($user)->get();
// get liked channels doesnt liked
Channel::query()->whereNotLikedBy($user)->get();
Likeable
use LaravelInteraction\Like\Tests\Models\User;
use LaravelInteraction\Like\Tests\Models\Channel;
/** @var \LaravelInteraction\Like\Tests\Models\User $user */
/** @var \LaravelInteraction\Like\Tests\Models\Channel $channel */
// Compare Fan
$channel->isLikedBy($user);
$channel->isNotLikedBy($user);
// Get fans info
$channel->fans->each(function (User $user){
echo $user->getKey();
});
$channels = Channel::query()->withCount('fans')->get();
$channels->each(function (Channel $channel){
echo $channel->fans()->count(); // 1100
echo $channel->fans_count; // "1100"
echo $channel->fansCount(); // 1100
echo $channel->fansCountForHumans(); // "1.1K"
});
Events
| Event | Fired |
|---|---|
LaravelInteraction\Like\Events\Liked |
When an object get liked. |
LaravelInteraction\Like\Events\Unliked |
When an object get unliked. |
License
Laravel Like is an open-sourced software licensed under the MIT license.