Friendable Polymorphic Eloquent Models for Laravel 5

2.2.0 2018-11-10 06:51 UTC


Build Status PHP from Packagist Latest Version License


Require this package, with Composer, in the root directory of your project.

$ composer require faustbrian/laravel-friendable

To get started, you'll need to publish the vendor assets and migrate:

php artisan vendor:publish --provider="BrianFaust\Friendable\FriendableServiceProvider" && php artisan migrate


Setup a Model


namespace App;

use BrianFaust\Friendable\HasFriends;
use Illuminate\Database\Eloquent\Model;

class User extends Model
    use HasFriends;


Send a Friend-Request to a Model


Unfriend a Model


Deny a Friend-Request from a Model


Accept a Friend-Request from a Model


Block a Model


Unblock a Model


Check if the Model has blocked another Model


Check if one Model is blocked by another Model


Check if a Friendship exists between two models


Get a single friendship


Get a list of all Friendships


Get a list of pending Friendships


Get a list of accepted Friendships


Get a list of denied Friendships


Get a list of blocked Friendships


Get a list of pending Friend-Requests



$ phpunit


If you discover a security vulnerability within this package, please send an e-mail to hello@brianfaust.me. All security vulnerabilities will be promptly addressed.



MIT © Brian Faust