1. Go to this page and download the library: Download zing/laravel-like library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zing / laravel-like example snippets
use Illuminate\Database\Eloquent\Model;
use LaravelInteraction\Like\Concerns\Fan;
class User extends Model
{
use Fan;
}
use Illuminate\Database\Eloquent\Model;
use LaravelInteraction\Like\Concerns\Likeable;
class Channel extends Model
{
use Likeable;
}
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();