2017 © Pedro Peláez
 

library friendly

Friends system for users, on Laravel.

image

gridprinciples/friendly

Friends system for users, on Laravel.

  • Wednesday, September 2, 2015
  • by gbrock
  • Repository
  • 3 Watchers
  • 11 Stars
  • 499 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 2 % Grown

The README.md

Friendly Build Status

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

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

Installation

  1. Run composer require gridprinciples/friendly from your project directory.
  2. Add the following to the providers array in config/app.php:, (*3)

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

    php artisan vendor:publish --provider="GridPrinciples\Friendly\Providers\FriendlyServiceProvider"
    
  4. Run the migrations:, (*5)

    php artisan migrate
    

    This will add a friends table to your database to track relationships between models., (*6)

Usage

Add the Friendly trait to your User model:
use Friendly;, (*7)

You may now relate users to each other:, (*8)


// 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:, (*9)

  • 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:, (*10)

$user->resetFriends();

The Versions

02/09 2015

dev-master

9999999-dev

Friends system for users, on Laravel.

  Sources   Download

The Development Requires

25/08 2015

0.1.0

0.1.0.0

Friends system for users, on Laravel.

  Sources   Download

The Development Requires