merodiro/friendships 问题修复 & 功能扩展

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

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

merodiro/friendships

Composer 安装命令:

composer require merodiro/friendships

包简介

This package gives users the ability to manage their friendships.

README 文档

README

Latest Version on Packagist Software License Build Status Build status Coverage Status Quality Score Total Downloads

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 $user is checking his own account
  • friends => if they are friends
  • waiting => if $user sent a request waiting for approval from $anotherUser
  • pending => if $anotherUser user sent a request waiting for approval from $user
  • not_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.

统计信息

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

GitHub 信息

  • Stars: 45
  • Watchers: 0
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固