Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kayw-geek/yii2-follow
🤳🏻This package helps you to add user based follow system to your model.
https://github.com/kayw-geek/yii2-follow
favorite follow followers like subscribe yii2-extension
Last synced: about 10 hours ago
JSON representation
🤳🏻This package helps you to add user based follow system to your model.
- Host: GitHub
- URL: https://github.com/kayw-geek/yii2-follow
- Owner: kayw-geek
- License: mit
- Created: 2020-09-17T06:32:57.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-18T23:34:17.000Z (about 4 years ago)
- Last Synced: 2024-09-23T22:31:22.586Z (4 days ago)
- Topics: favorite, follow, followers, like, subscribe, yii2-extension
- Language: PHP
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Yii2 Follow
User follow unfollow system for Yii2.
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkayw-geek%2Fyii2-follow.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fkayw-geek%2Fyii2-follow?ref=badge_shield) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/kayw-geek/yii2-follow) ![GitHub](https://img.shields.io/github/license/kayw-geek/yii2-follow)
## Installing
```
$ composer require kayw-geek/yii2-follow
```### Migrations
This step is also optional, if you want to custom the pivot table, you can publish the migration files:
```
$ yii migrate/up --migrationPath=@vendor/kayw-geek/yii2-follow/migrations
```## Usage
### Traits
#### kaywGeek\Follow\FollowerTrait
```php
use kaywGeek\follow\FollowerTrait;
use Yii;
use yii\base\NotSupportedException;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use yii\web\IdentityInterface;class User extends ActiveRecord implements IdentityInterface
{
<...>
use FollowerTrait;
<...>
}
```### API
```php
$user1 = User::findOne(1);
$user2 = User::findOne(2);$user1->follow($user2);
$user1->unfollow($user2);
$user1->checkFollowed($user2);
$user1->followedCount();
$user1->followerCount();
```#### Get followings:
```php
$user->followings;
```#### Get followers:
```php
$user->followers;
```### Aggregations
```php
// with query where
$user->followings()->where(['<',['follow_at'=>date('Y-m-d')]])->all();// followers orderBy
$user->followers()->orderBy('follow_at desc');
```# License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkayw-geek%2Fyii2-follow.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fkayw-geek%2Fyii2-follow?ref=badge_large)