merodiro/friendships
Composer 安装命令:
composer require merodiro/friendships
包简介
This package gives users the ability to manage their friendships.
README 文档
README
This package gives users the ability to manage their friendships.
Models can:
- Send Friend Requests
- Accept Friend Requests
- Deny Friend Requests
- Delete Friend
Installation
First, install the package through Composer.
composer require merodiro/friendships
Then include the service provider inside config/app.php.
'providers' => [ ... Merodiro\Friendships\FriendshipsServiceProvider::class, ... ];
Finally, migrate the database
php artisan migrate
Setup a Model
use Merodiro\Friendships\Friendable; class User extends Model { use Friendable; ... }
How to use
Check the Test file to see the package in action
Send a Friend Request
$user->addFriend($recipient);
Accept a Friend Request
$user->acceptFriend($sender);
Deny a Friend Request
$user->deleteFriend($sender);
Remove Friend
$user->deleteFriend($friend);
Mutual Friends
$user->mutualFriends($anotherUser);
check the current relationship between two users
$user->checkFriendship($anotherUser);
it returns
same_user=> if the$useris checking his own accountfriends=> if they are friendswaiting=> if$usersent a request waiting for approval from$anotherUserpending=> if$anotherUseruser sent a request waiting for approval from$usernot_friends=> if they are not friends
Check if two users are friends
$user->isFriendsWith($anotherUser);
it returns true if they are friends and false if they aren't
Friends
To get a collection of users use the following methods:
Get Friends
$user->friends();
Get a list of users that $user has received friend requests from
$user->friendRequestsReceived();
Get a list of users that $user has sent friend requests to
$user->friendRequestsSent();
Events
This is the list of the events fired by default for each action
| Event name | Fired |
|---|---|
| friendrequest.sent | When a friend request is sent |
| friendrequest.accepted | When a friend request is accepted |
| friendship.deleted | When a friend request is denied |
| friendship.deleted | When a friendship is deleted |
for more about how to use the events Check this example
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security-related issues, please email merodiro@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
merodiro/friendships 适用场景与选型建议
merodiro/friendships 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.69k 次下载、GitHub Stars 达 45, 最近一次更新时间为 2017 年 05 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「friends」 「friendships」 「eloquent」 「friend-system」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 merodiro/friendships 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 merodiro/friendships 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 merodiro/friendships 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Eloquent Befriended brings social media-like features like following, blocking and filtering content based on following or blocked models.
This package gives Eloquent models the ability to manage their followers.
This package gives Eloquent models the ability to manage their friendships.
Alfabank REST API integration
This package gives Eloquent models the ability to manage their friendships.
This light package, with no dependencies, gives Eloquent models the ability to manage friendships (with groups). And interactions such as: Likes, favorites, votes, subscribe, follow, ..etc. And it includes advanced rating system.
统计信息
- 总下载量: 9.69k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 45
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-05-08