New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

gridprinciples/friendly

Friends system for users, on Laravel.
528 10

Larablocks Analysis

gridprinciples/friendly works with any PHP project: the latest release (0.1.0, Aug 25, 2015) doesn't depend on Laravel.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • No release in the last 12 months (last: Aug 25, 2015)
  • 1 downloads a month (needs 10,000)
  • 10 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: Aug 25, 2015.
  • No releases in the last 12 months.
  • First released: Aug 25, 2015.
  • Monthly downloads: 1.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 26, 2026.

Install
composer require gridprinciples/friendly
Latest Version:0.1.0
Last Updated:Sep 2, 2015
Links: GitHub  ·  Packagist
Maintainer: gbrock

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.

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();

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

670,032,257 9,703
laravel/framework

The Laravel Framework.

640,572,096 35,338
laravel/tinker

Powerful REPL for the Laravel framework.

546,909,908 7,440
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

465,816,364 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

431,187,642 4,660

Version History

Version Released License
0.1.0