Download the PHP package arubacao/friends without Composer
On this page you can find all versions of the php package arubacao/friends. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download arubacao/friends
More information about arubacao/friends
Files in arubacao/friends
Informations about the package friends
Unmaintained
This package is unmaintained and was only a quick hacking around. Don't use in production code.
Friends (Laravel 5 Package)
Organise Friends and Relationships Between Users in Laravel and Lumen.
Friends provides everything you need to easily implement your own Facebook like Friend System.
Users can:
- Send Friend Requests
- Accept Friend Requests
- Deny Friend Requests
- Delete Friends
Contents
- Installation
- Configuration
- Usage
- Friend Requests
- Send Friend Request
- Accept Friend Request
- Deny Friend Request
- My Friends
- Is Friend With
- Delete Friend
- Retrieve Friends
- Retrieve Incoming Friends
- Retrieve Any Friends
- Relationships
- Has Relationship With
- Get Relationship With
- Has Pending Request From
- Query Users Including Relationships
- Friend Requests
- License
Installation
For Laravel 5.*
Pull in Package with Composer
composer require arubacao/friends
Register Service Provider
Include the service provider inside config/app.php.
Run Migrations
Publish the migration and migrate the database
After the migration, 1 new table will be created:
friends— stores relationships/friendships between Users
The vendor:publish command will also create a friends.php file in your config directory.
The default configuration should work just fine for most applications.
Otherwise check out Configuration.
Prepare User Model
Include Friendable Trait in User Model
And you are ready to go.
Configuration
Configuration File friends.php (Optional)
Find friends.php in your config folder. Make sure you published the package beforehand.
user_model— This is the applicationsUsermodel used by Friends.users_table— This is the applicationsuserstable name used by Friends.
Usage
Friend Requests
Send Friend Request
$user must be instance of User
$recipient must be instance of User, User array or integer (User id)
Accept Friend Request
$user must be instance of User
$sender must be instance of User, User array or integer (User id)
Deny Friend Request
$user must be instance of User
$sender must be instance of User, User array or integer (User id)
My Friends
Delete Friend
$user must be instance of User
$douchebag must be instance of User, User array or integer (User id)
Retrieve Friends
- Get all friends of a user
statusis always1ACCEPTED
$user must be instance of User
$friends:
Retrieve Incoming Friends
- Get all users who send friend request to
$user statusis always0PENDINGrecipient_idis alwaysidof$user
$user must be instance of User
$friends:
Retrieve Any Friends
Remember:
Just like in the real life a 'friend' or 'friendship' can be anything, also negative ;)
- Get all users who have any kind of friendship/relationship with
$user
$user must be instance of User
$friends:
Relationships
Has Relationship With
$user must be instance of User
$person must be instance of User, User array or integer (User id)
$status must be array of integers (Status)
Get Relationship With
$user must be instance of User
$person must be instance of User, User array or integer (User id)
$status must be array of integers (Status)
Has Pending Request From
$user must be instance of User
$person must be instance of User, User array or integer (User id)
Query Users Including Relationships
$users:
License
Friends is free software distributed under the terms of the MIT license.
