Package Data | |
---|---|
Maintainer Username: | skybluesofa |
Maintainer Contact: | connect@skybluesofa.com (Dave Rogers) |
Package Create Date: | 2016-09-06 |
Package Last Update: | 2020-03-08 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:20:48 |
Package Statistics | |
---|---|
Total Downloads: | 10,755 |
Monthly Downloads: | 27 |
Daily Downloads: | 1 |
Total Stars: | 60 |
Total Watchers: | 3 |
Total Forks: | 10 |
Total Open Issues: | 0 |
Gives Eloquent models the ability to manage their followers.
##Models can:
First, install the package through Composer.
composer require skybluesofa/laravel-followers
Then include the service provider inside config/app.php
.
'providers' => [
...
Skybluesofa\Followers\ServiceProvider::class,
...
];
Publish config and migrations
php artisan vendor:publish --provider="Skybluesofa\Followers\ServiceProvider"
Configure the published config in
config\followers.php
Finally, migrate the database
php artisan migrate
use Skybluesofa\Followers\Traits\Followable;
class User extends Model
{
use Followable;
...
}
Check the Test file to see the package in action
$user->follow($recipient);
$recipient->acceptFollowRequestFrom($user);
$user->canFollow($recipient);
$recipient->denyFollowRequestFrom($user);
$user->unfollow($recipient);
$user->blockBeingFollowedBy($recipient);
$user->unblockBeingFollowedBy($recipient);
$user->isFollowing($recipient);
$recipient->isFollowedBy($user);
$recipient->hasFollowRequestFrom($user);
$user->hasSentFollowRequestTo($recipient);
$recipient->hasBlockedBeingFollowedBy($user);
$user->isBlockedFromFollowing($recipient);
$user->getFollowing($recipient);
$user->getFollowingList();
$user->getFollowingList($per_page = 20);
$user->getAcceptedRequestsToFollow();
$user->getPendingRequestsRequestsToFollow();
$user->getDeniedRequestsToFollow();
$user->getBlockedFollowing();
$user->getAllFollowing();
$user->getBlockedFriendships();
$user->getFollowingCount();
To get a collection of friend models (ex. User) use the following methods:
$user->following();
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.
See the CONTRIBUTING guide.