Download the PHP package giliomeejg/laravel-friendships without Composer
On this page you can find all versions of the php package giliomeejg/laravel-friendships. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download giliomeejg/laravel-friendships
More information about giliomeejg/laravel-friendships
Files in giliomeejg/laravel-friendships
Package laravel-friendships
Short Description This package gives Eloquent models the ability to manage their friendships.
License MIT
Informations about the package laravel-friendships
Laravel 5 Friendships
This is a clone of hootlex/laravel-friendships that includes support for Laravel 5.8 as the original package does not seem to be maintained anymore.
This package gives Eloquent models the ability to manage their friendships. You can easily design a Facebook like Friend System.
Models can:
- Send Friend Requests
- Accept Friend Requests
- Deny Friend Requests
- Block Another Model
- Group Friends
Installation
First, install the package through Composer.
If you are using Laravel < 5.5, you need to add giliomeejg\Friendships\FriendshipsServiceProvider to your config/app.php
providers array:
Publish config and migrations
Configure the published config in
Finally, migrate the database
Setup a Model
How to use
Check the Test file to see the package in action
Send a Friend Request
Accept a Friend Request
Deny a Friend Request
Remove Friend
Block a Model
Unblock a Model
Check if Model is Friend with another Model
Check if Model has a pending friend request from another Model
Check if Model has already sent a friend request to another Model
Check if Model has blocked another Model
Check if Model is blocked by another Model
Get a single friendship
Get a list of all Friendships
Get a list of pending Friendships
Get a list of accepted Friendships
Get a list of denied Friendships
Get a list of blocked Friendships
Get a list of pending Friend Requests
Get the number of Friends
Get the number of Pendings
Get the number of mutual Friends with another user
Friends
To get a collection of friend models (ex. User) use the following methods:
Get Friends
Get Friends Paginated
Get Friends of Friends
Collection of Friends in specific group paginated:
Get mutual Friends with another user
Friend groups
The friend groups are defined in the config/friendships.php
file.
The package comes with a few default groups.
To modify them, or add your own, you need to specify a slug
and a key
.
Since you've configured friend groups, you can group/ungroup friends using the following methods.
Group a Friend
Remove a Friend from family group
Remove a Friend from all groups
Get the number of Friends in specific group
To filter friendships
by group you can pass a group slug.
Events
This is the list of the events fired by default for each action
Event name | Fired |
---|---|
friendships.sent | When a friend request is sent |
friendships.accepted | When a friend request is accepted |
friendships.denied | When a friend request is denied |
friendships.blocked | When a friend is blocked |
friendships.unblocked | When a friend is unblocked |
friendships.cancelled | When a friendship is cancelled |
Contributing
See the CONTRIBUTING guide.