2017 © Pedro Peláez
 

library laravel-followers

This package gives Eloquent models the ability to manage their followers.

image

skybluesofa/laravel-followers

This package gives Eloquent models the ability to manage their followers.

  • Monday, January 2, 2017
  • by skybluesofa
  • Repository
  • 3 Watchers
  • 48 Stars
  • 975 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 0 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

Laravel 5 Followers

Build Status Code Climate Test Coverage Total Downloads Version Software License, (*1)

Gives Eloquent models the ability to manage their followers., (*2)

Models can:

  • Send Follow Requests
  • Accept Follow Requests
  • Deny Follow Requests
  • Block Another Model

Installation

First, install the package through Composer., (*3)

composer require skybluesofa/laravel-followers

Then include the service provider inside config/app.php., (*4)

'providers' => [
    ...
    Skybluesofa\Followers\ServiceProvider::class,
    ...
];

Publish config and migrations, (*5)

php artisan vendor:publish --provider="Skybluesofa\Followers\ServiceProvider"

Configure the published config in, (*6)

config\followers.php

Finally, migrate the database, (*7)

php artisan migrate

Setup a Model

use Skybluesofa\Followers\Traits\Followable;
class User extends Model
{
    use Followable;
    ...
}

How to use

Check the Test file to see the package in action, (*8)

Methods

Send a Follow Request

Will trigger a Skybluesofa\LaravelFollowers\Events\FollowRequest event., (*9)

$user->follow($recipient);

Accept a Follow Request

Will trigger a Skybluesofa\LaravelFollowers\Events\FollowRequestAccepted event., (*10)

$recipient->acceptFollowRequestFrom($user);

Deny a Follow Request

Will trigger a Skybluesofa\LaravelFollowers\Events\FollowRequestDenied event., (*11)

$recipient->denyFollowRequestFrom($user);

Remove Follow

Will trigger a Skybluesofa\LaravelFollowers\Events\Unfollow event., (*12)

$user->unfollow($recipient);

Block a User

Will trigger a Skybluesofa\LaravelFollowers\Events\FollowingBlocked event., (*13)

$user->blockBeingFollowedBy($recipient);

Unblock a User

Will trigger a Skybluesofa\LaravelFollowers\Events\FollowingUnblocked event., (*14)

$user->unblockBeingFollowedBy($recipient);

Check if User is Following another User

$user->isFollowing($recipient);

Check if User is being Followed by another User

$recipient->isFollowedBy($user);

Check if User has a pending Follow request from another User

$recipient->hasFollowRequestFrom($user);

Check if User sent a pending Follow request to another User

$user->hasSentFollowRequestTo($recipient);

Check if User has blocked another User

$recipient->hasBlockedBeingFollowedBy($user);

Check if User is blocked by another User

$user->isBlockedFromFollowing($recipient);

Get a single friendship

$user->getFriendship($recipient);

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();

Get the number of Friends

$user->getFriendsCount();

Friends

To get a collection of friend models (ex. User) use the following methods:, (*15)

Get Friends

$user->getFriends();

Get Friends Paginated

$user->getFriends($perPage = 20);

Events

These events are triggered during the lifecycle of following/unfollowing/accept/deny followers:, (*16)

Skybluesofa\LaravelFollowers\Events\FollowingBlocked(Model $recipient, Model $sender);
Skybluesofa\LaravelFollowers\Events\FollowingUnblocked(Model $recipient, Model $sender);
Skybluesofa\LaravelFollowers\Events\FollowRequest(Model $recipient, Model $sender);
Skybluesofa\LaravelFollowers\Events\FollowRequestAccepted(Model $recipient, Model $sender);
Skybluesofa\LaravelFollowers\Events\FollowRequestDenied(Model $recipient, Model $sender);
Skybluesofa\LaravelFollowers\Events\Unfollow(Model $recipient, Model $sender);

To listen for and react to these events, follow the instructions available in the Laravel Documentation., (*17)

Thank you

The basis of this code was garnered from https://github.com/hootlex/laravel-friendships. Although it was a jumping off point, much of the code has been rewritten to allow for Following as opposed to Mutual Friendship., (*18)

Contributing

See the CONTRIBUTING guide., (*19)

The Versions

02/01 2017

dev-master

9999999-dev

This package gives Eloquent models the ability to manage their followers.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

laravel friends eloqent followers

08/09 2016

1.0.0

1.0.0.0

This package gives Eloquent models the ability to manage their followers.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

laravel friends eloqent followers