1. Go to this page and download the library: Download jobmetric/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/ */
jobmetric / laravel-like example snippets
use JobMetric\Reaction\HasReaction;
class Article extends Model
{
use HasReaction;
}
use JobMetric\Reaction\CanReact;
class User extends Model
{
use CanReact;
}
$article->addReaction('like', $user); // with user
$article->addReaction('like', null, ['device_id' => 'abc123']); // anonymous
$article->toggleReaction('like', $user); // Adds if not exists, removes if exists
$article->removeReaction('like', $user);
$article->removeAllReactions($user); // or pass device_id