1. Go to this page and download the library: Download edram/laravel-interactions 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/ */
use Edram\LaravelInteractions\Concerns\Interactable;
use Edram\LaravelInteractions\Concerns\Interacts;
class User extends Authenticatable
{
use Interactable;
use Interacts;
}
class Post extends Model
{
use Interactable;
}
class Comment extends Model
{
use Interactable;
}
use Edram\LaravelInteractions\Concerns\Actor\Follows;
use Edram\LaravelInteractions\Concerns\Actor\HasInteractions;
use Edram\LaravelInteractions\Concerns\Actor\Likes;
use Edram\LaravelInteractions\Concerns\Target\HasFollowers;
use Edram\LaravelInteractions\Concerns\Target\HasLikers;
use Edram\LaravelInteractions\Concerns\Target\ReceivesInteractions;
class User extends Authenticatable
{
use HasInteractions;
use Follows;
use Likes;
use ReceivesInteractions;
use HasFollowers;
}
class Post extends Model
{
use ReceivesInteractions;
use HasLikers;
}
class Team extends Model
{
use Interactable;
use Interacts;
}
$user->like($post);
$team->like($post);
$post->likers()->get(); // User from default_actor
$post->likers(Team::class)->get(); // Team
$user->follow($team);
$team->followers()->get(); // User from default_actor
$team->followers(Team::class)->get();