All Projects → hypefactors → laravel-follow

hypefactors / laravel-follow

Licence: BSD-3-Clause license
Laravel Follow System for Eloquent models.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to laravel-follow

booster
twitter bot that builds followers
Stars: ✭ 30 (-33.33%)
Mutual labels:  followers
laravel-favorite
❤️ User favorite feature for Laravel Application.
Stars: ✭ 183 (+306.67%)
Mutual labels:  followers
github-unfollower-detector
💀 Small application to detect evil users who have stopped following you on Github 💀
Stars: ✭ 42 (-6.67%)
Mutual labels:  followers
goodreads-toolbox
9 tools for Goodreads.com, for finding people based on the books they’ve read, finding books popular among the people you follow, following new book reviews, etc
Stars: ✭ 56 (+24.44%)
Mutual labels:  followers
meet-the-fans
Query and Visualize the network graph of your GitHub repositories, followers, stargazers, and forks.
Stars: ✭ 22 (-51.11%)
Mutual labels:  followers
bot
Completely free and open-source human-like Instagram bot. Powered by UIAutomator2 and compatible with basically any Android device 5.0+ that can run Instagram - real or emulated.
Stars: ✭ 321 (+613.33%)
Mutual labels:  followers
SocialMediaAppForFoodies
This is a Social networking android app for food lovers. It is a way to connect with other foodies and grow your network of friends and followers. In this app we can, 1.Users can create their own account and maintain it. 2.Post the Recipes with image and Description. 3.Followers can like and Comment on your post 4.Home screen with your and whom …
Stars: ✭ 40 (-11.11%)
Mutual labels:  followers
Insta-Bot
Python bot using Selenium increasing Instagram Followers.
Stars: ✭ 62 (+37.78%)
Mutual labels:  followers
ouuan
A profile README with 86 stars and 152 forks 🌟
Stars: ✭ 86 (+91.11%)
Mutual labels:  followers
Arduino-OpenCV-Human-Follower
Face detector and follower using Arduino and OpenCV in Python
Stars: ✭ 30 (-33.33%)
Mutual labels:  followers
BeRude
A fun tool that lists all users who don't follow you back on GitHub😁
Stars: ✭ 33 (-26.67%)
Mutual labels:  followers
mastodon-autofollow
Autofollow bot for mastodon
Stars: ✭ 28 (-37.78%)
Mutual labels:  followers

Laravel Follow

Build Status Software License Latest Version on Packagist Total Downloads

Laravel 9 Follow System for Eloquent models.

This package is compliant with the FIG standards PSR-1, PSR-2 and PSR-4 to ensure a high level of interoperability between shared PHP. If you notice any compliance oversights, please send a patch via pull request.

Version Matrix

Version Laravel PHP Version
8.x 9.x >= 8.0
7.x 8.x >= 7.3
6.x 7.x >= 7.2.5
5.x 6.x >= 7.2
4.x 5.8.x >= 7.1
3.x 5.7.x >= 7.1
2.x 5.6.x >= 7.1
1.x 5.5.x >= 7.0

Installation

You can install the package via composer:

composer require hypefactors/laravel-follow

The package will be automatically registered.

Now you need to run the migrations:

php artisan migrate

Usage

Preparing the Eloquent Models

To allow an entity to be followed or to follow other entities, the corresponding models have to implement an interface and make usage of a trait.

Here's how we do it for a User and Company entity, where a user will be able to follow a company and the company will be able to be followed:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Hypefactors\Laravel\Follow\Traits\CanFollow;
use Hypefactors\Laravel\Follow\Contracts\CanFollowContract;

class User extends Model implements CanFollowContract
{
    use CanFollow;
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Hypefactors\Laravel\Follow\Traits\CanBeFollowed;
use Hypefactors\Laravel\Follow\Contracts\CanBeFollowedContract;

class Company extends Model implements CanBeFollowedContract
{
    use CanBeFollowed;
}

Note: If required, an entity can follow and can also be followed, just implement both interfaces and traits on the same model to achieve that requirement.

Following an Entity

You can follow an entity like this:

$company = Company::find(1);

$user = User::find(1);
$user->follow($company);

You can also perform the same through the entity that's going to be followed:

$user = User::find(1);

$company = Company::find(1);
$company->addFollower($user);

Follow Many Entities

You can follow many entities like this:

$companies = Company::whereIn('id', [1, 3, 10])->get();

$user = User::find(1);
$user->followMany($companies);

You can also perform the same through the entity that's going to be followed:

$users = User::whereIn('id', [1, 3, 10])->get();

$company = Company::find(1);
$company->addManyFollowers($users);

Unfollowing an Entity

You can unfollow an entity like this:

$company = Company::find(1);

$user = User::find(1);
$user->unfollow($company);

You can also perform the same through the entity that's going to be unfollowed:

$user = User::find(1);

$company = Company::find(1);
$company->removeFollower($user);

Unfollow Many Entities

You can unfollow many entities like this:

$companies = Company::whereIn('id', [1, 3, 10])->get();

$user = User::find(1);
$user->unfollowMany($companies);

You can also perform the same through the entity that's going to be unfollowed:

$users = User::whereIn('id', [1, 3, 10])->get();

$company = Company::find(1);
$company->removeManyFollowers($users);

Determining if an Entity is Following another Entity

You can unfollow an entity like this:

$company = Company::find(1);

$user = User::find(1);
$user->isFollowing($company);

You can also perform the same through the entity that's going to be followed:

$user = User::find(1);

$company = Company::find(1);
$company->hasFollower($user);

Determine if an Entity has Followings

$user = User::find(1);

if ($user->hasFollowings()) {
    echo "User is following {$user->followings->count()} entities.";
}

Determine if an Entity has Followers

$company = Company::find(1);

if ($company->hasFollowers()) {
    echo "Company has {$company->followers->count()} followers.";
}

Get list of Followings

To get a list of followings (entities another entity is following)

$user = User::find(1);

$followings = $user->followings

Get List of Followers

To get a list of followers (entities that are following an entity)

$company = Company::find(1);

$followers = $company->followers

Get List of Followings by Entity Type

Get a list of followings (entities another entity is following) and filter by an entity type

$user = User::find(1);

$followings = $user->followings()->whereFollowableType(Company::class)->get();

Get List of Followers by Entity Type

Get a list of followers (entities that are following an entity) and filter by an entity type

$company = Company::find(1);

$followers = $company->followers()->whereFollowerType(User::class)->get();

Contributing

Thank you for your interest in Laravel Follow. Here are some of the many ways to contribute.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

Laravel Follow is licenced under the BSD 3-Clause License. Please see the license file for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].