questocat/laravel-rally 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

questocat/laravel-rally

Composer 安装命令:

composer require questocat/laravel-rally

包简介

A followers system for laravel 5

README 文档

README

A followers system for laravel 5, Trait for Laravel Eloquent models to allow easy implementation of a "follow" or "like" or "favorite" or "remember" or "subscribe" feature.

StyleCI Scrutinizer Code Quality Build Status Packagist

Installation

Via Composer to add the package to your project's dependencies:

$ composer require questocat/laravel-rally

First add service providers into the config/app.php

\Questocat\Rally\RallyServiceProvider::class,

Publish the migrations

$ php artisan vendor:publish --provider="Questocat\Rally\RallyServiceProvider" --tag="migrations"

Publish the config

$ php artisan vendor:publish --provider="Questocat\Rally\RallyServiceProvider" --tag="config"

Setup the model

Add CanFollow Traits to your User model.

use Questocat\Rally\Traits\CanFollow

class User extends Model
{
    use CanFollow;
}

Add CanBeFollowed Trait to your Post model or Video model and more.

use Questocat\Rally\Traits\CanBeFollowed

class Post extends Model
{
    use CanBeFollowed;
}

Add CanFollow and CanBeFollowed feature trait into your User model:

use Questocat\Rally\Traits\Followable

class User extends Model
{
    use Followable;
}

Usage

CanFollow

Follow and Unfollow users

$user->follow(1);  // App\User:class
$user->follow($user1);
$user->follow([1, 3]);
$user->follow(1, Post::class);

$user->unfollow(1);  // App\User:class
$user->unfollow($user1);
$user->unfollow([1, 2]);
$user->unfollow(1, Post::class);

Check if being followed by someone

$user->isFollowing(1);
$user->isFollowing($user2);
$user->isFollowing(2, Post::class);
$user->isFollowing($post, Post::class);

Toggle follow

$user->toggleFollow(1);
$user->toggleFollow($user2);
$user->toggleFollow([2, 4]);
$user->toggleFollow([2, 4], Post::class);

Following

$user->following;
$user->following()->get();    // It's the same thing as this
$user->following()->count();  // Get the total following
CanBeFollowed

Check if following by someone

$user->isFollowedBy(3);
$user->isFollowedBy($user2);

Followers

$user->followers;
$user->followers()->get();    // It's the same thing as this
$user->followers()->count();  // Get the total followers
Followable

Check if it is mutual follow

$user->isMutualFollow(1);
$user->isMutualFollow($user2);

Inspiration

License

Licensed under the MIT license.

统计信息

  • 总下载量: 107
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固