PHP code example of bitfumes / laravel-likker

1. Go to this page and download the library: Download bitfumes/laravel-likker 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/ */

    

bitfumes / laravel-likker example snippets


use Illuminate\Database\Eloquent\Model;
use Bitfumes\Likker\Contracts\Likeable;
use Bitfumes\Likker\Traits\CanBeLiked;

class Post extends Model implements Likeable
{
    use CanBeLiked;
}

use Illuminate\Foundation\Auth\User as Authenticatable;
use Bitfumes\Likker\Contracts\Liker;
use Bitfumes\Likker\Traits\CanLike;

class User extends Authenticatable implements Liker
{
    use CanLike;
}

// Like by authenticated user
$post->likeIt();
// Like by any user
$post->likeIt($user);

// Remove Like by authenticated user
$post->unLikeIt();
// Like by any user
$post->unLikeIt($user);

// Toggle like by authenticated user
$post->toggleLike();
// Toggle like by any user
$post->toggleLike($user);

// Return boolean
$post->isLiked();

// it counts the like for given model
$post->countLikes();