skybluesofa/laravel-followers 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

skybluesofa/laravel-followers

Composer 安装命令:

composer require skybluesofa/laravel-followers

包简介

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

README 文档

README

Build Status Code Climate Test Coverage Total Downloads Version Software License

Gives Eloquent models the ability to manage their followers.

Models can:

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

Installation

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

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

Methods

Send a Follow Request

Will trigger a Skybluesofa\LaravelFollowers\Events\FollowRequest event.

$user->follow($recipient);

Accept a Follow Request

Will trigger a Skybluesofa\LaravelFollowers\Events\FollowRequestAccepted event.

$recipient->acceptFollowRequestFrom($user);

Deny a Follow Request

Will trigger a Skybluesofa\LaravelFollowers\Events\FollowRequestDenied event.

$recipient->denyFollowRequestFrom($user);

Remove Follow

Will trigger a Skybluesofa\LaravelFollowers\Events\Unfollow event.

$user->unfollow($recipient);

Block a User

Will trigger a Skybluesofa\LaravelFollowers\Events\FollowingBlocked event.

$user->blockBeingFollowedBy($recipient);

Unblock a User

Will trigger a Skybluesofa\LaravelFollowers\Events\FollowingUnblocked event.

$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:

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:

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.

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.

Contributing

See the CONTRIBUTING guide.

skybluesofa/laravel-followers 适用场景与选型建议

skybluesofa/laravel-followers 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.95k 次下载、GitHub Stars 达 60, 最近一次更新时间为 2016 年 09 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「friends」 「Followers」 「eloqent」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 skybluesofa/laravel-followers 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 skybluesofa/laravel-followers 我们能提供哪些服务?
定制开发 / 二次开发

基于 skybluesofa/laravel-followers 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 10.95k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 60
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 60
  • Watchers: 3
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-09-06