AbdullahGhanem / friendship by ghanem

friendship system for Laravel 5
136
18
2
Package Data
Maintainer Username: ghanem
Maintainer Contact: 3bdullah.ghanem@gmail.com (abdullah ghanem)
Package Create Date: 2015-10-23
Package Last Update: 2015-11-25
Language: PHP
License: MIT
Last Refreshed: 2024-11-11 15:20:13
Package Statistics
Total Downloads: 136
Monthly Downloads: 1
Daily Downloads: 1
Total Stars: 18
Total Watchers: 2
Total Forks: 0
Total Open Issues: 2

Laravel Friendship

This package will allow you to add a full report system into your Laravel application.

Installation

First, pull in the package through Composer.

composer require ghanem/friendship

And then include the service provider within app/config/app.php.

'providers' => [
    Ghanem\Friendship\FriendshipServiceProvider::class
];

At last you need to publish

php artisan vendor:publish --provider="Ghanem\Friendship\FriendshipServiceProvider" 

and run the migration.

php artisan migrate

Setup a Model

<?php

namespace App;

use Ghanem\Friendship\Contracts\Friendable;
use Ghanem\Friendship\Traits\Friendable as FriendableTrait;
use Illuminate\Database\Eloquent\Model;

class User extends Model implements Friendable
{
    use FriendableTrait;
}

Examples

Send a Friend-Request to a Model

$user->befriend($userToBeFriendsWith);

Unfriend a Model

$user->unfriend($userToBeFriendsWith);

Deny a Friend-Request from a Model

$user->denyFriendRequest($userToBeFriendsWith);

Accept a Friend-Request from a Model

$user->acceptFriendRequest($userToBeFriendsWith);

Block a Model

$user->blockFriendRequest($userToBeFriendsWith);

Unblock a Model

$user->unblockFriendRequest($userToBeFriendsWith);

Check if the Model has blocked another Model

$user->hasBlocked($userToBeFriendsWith);

Check if one Model is blocked by another Model

$user->isBlockedBy($userToBeFriendsWith);

Check if a Friendship exists between two models

$user->isFriendsWith($userToBeFriendsWith);

Get a single friendship

$user->getFriendship($userToBeFriendsWith);

Get a list of all Friendships

$user->getAllFriendships();

Get a list of pending Friendships

$user->getPendingFriendships();

Get a list of accepted Friendships

$user->getAcceptedFriendships();

Get a list of denied Friendships

$user->getDeniedFriendships();

Get a list of blocked Friendships

$user->getBlockedFriendships();

Get a list of pending Friend-Requests

$user->getFriendRequests();