定制 gridprinciples/friendly 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

gridprinciples/friendly

最新稳定版本:0.1.0

Composer 安装命令:

composer require gridprinciples/friendly

包简介

Friends system for users, on Laravel.

README 文档

README

A Laravel 5.1 package designed to enhance Eloquent users with connections between users, including approvals by both users and additional data.

Friendly includes many shortcuts to creating one's own Friend system, but the developer is free to implement the details however they require.

Installation

  1. Run composer require gridprinciples/friendly from your project directory.

  2. Add the following to the providers array in config/app.php:

    GridPrinciples\Friendly\Providers\FriendlyServiceProvider::class,
  3. Publish the migrations and config file:

    php artisan vendor:publish --provider="GridPrinciples\Friendly\Providers\FriendlyServiceProvider"
    
  4. Run the migrations:

    php artisan migrate
    

    This will add a friends table to your database to track relationships between models.

Usage

Add the Friendly trait to your User model:
use Friendly;

You may now relate users to each other:

// Using the "requesting" user model...
$dad = User::where('name', 'darth')->first();

// ...and the one receiving the friend request...
$kid = User::where('name', 'luke')->first();

// may include "pivot" data.
$dad->befriend($kid, [
    'name'       => 'Father',
    'other_name' => 'Son',
    'start'      => '1980-05-21',
]);

// ...and later, the secondary user approves the request:
$kid->approve($dad);

// At this point, either user is associated with the other via their `friends` attribute (a Collection):
$relatives = $kid->friends->toArray();

// Either user may sever the relationship, resulting in a type of block:
$kid->block($dad);

Pivot Data

The included implementation table includes the following additional information about each friend request:

  • name: Describes the requesting user's relationship with the secondary user.
  • other_name: Describes the secondary user's relationship with the requesting user.
  • start: When the relationship started, or will start.
  • end: When the relationship

Reloading the Connections

When time you access the "friends" property on a user Model, the connections will be loaded and cached. If you make changes to a different relationship which would affect a loaded user's friends, you might need to reload them:

$user->resetFriends();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-08-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固