LaravelPackages.net
Acme Inc.
Toggle sidebar
gregoryduckworth/friendable

Add the possibility of friends quickly with the use of this trait.

20
2
0.2
About gregoryduckworth/friendable

gregoryduckworth/friendable is a Laravel package for add the possibility of friends quickly with the use of this trait.. It currently has 2 GitHub stars and 20 downloads on Packagist (latest version 0.2). Install it with composer require gregoryduckworth/friendable. Discover more Laravel packages by gregoryduckworth or browse all Laravel packages to compare alternatives.

Last updated

Friendable

Latest Stable Version Total Downloads Build Status License

Add the possibility of friends quickly with the use of this trait.

Requirements

  • PHP 8.2+
  • Laravel 9.6+, 10.x, 11.x, or 12.x

Install

Via Composer

$ composer require gregoryduckworth/friendable

The service provider will be automatically registered via Laravel's package auto-discovery.

Publish and run the migration:

php artisan vendor:publish --provider="GregoryDuckworth\Friendable\FriendableServiceProvider" --tag="migrations"
php artisan migrate

Usage

Add the Trait to the User Model

use GregoryDuckworth\Friendable\Traits\Friendable;

class User extends Model
{
    use Friendable;
    ...
}

Examples

List all the users confirmed friends

    $user->confirmedFriends();

List all the users pending friends

    $user->pendingFriends();

List all the friends waiting to approve the user

    $user->awaitingApproval();

Request the friendship of another user

    $user->requestFriendship(Model $friend);

Confirm the friendship

    $user->confirmFriendship(Model $friend);

Remove the friendship

    $user->removeFriendship(Model $friend);

Todo

  • Add tests (inc travis builds)
  • Ability to block friends

Change log

Please see CHANGELOG for more information what has changed recently.

License

The MIT License (MIT). Please see License File for more information.

Comments