承接 se468/laravel-ratings 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

se468/laravel-ratings

Composer 安装命令:

composer require se468/laravel-ratings

包简介

Laravel Ratings Engine

README 文档

README

Latest Stable Version Total Downloads License

Ratings engine for Laravel using polymorphic relationships.

DEMO : here

Installation

  1. composer require se468/laravel-ratings
  2. php artisan migrate to migrate the tables
  3. Add CanReceiveRatings trait to your model that receives Ratings (App\User, App\Company, App\Project .. whatever you need to receive ratings for) and implement RatingReceivable interface to the model.
  4. Add CanGiveRatings trait to your model that needs to give Ratings (Usually App\User).

Example (CanGiveRatings):

<?php
namespace App;
use se468\Ratings\RatingGivable;
...

class User extends Authenticatable
{
    use CanGiveRating;

    ...
}

Example (CanReceiveRatings):

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use se468\Ratings\RatingReceivable;
use se468\Ratings\Traits\CanReceiveRating;
...

class Company extends Model implements RatingReceivable
{
    use CanReceiveRating;

    ...
}

Usage

Basic Usage Example

public function rateCompany(Request $request)
{
    $input = $request->all();
    $company = Company::find($input["id"]);
    
    auth()->user()->rate($company, $input["rating"], 'Some Comment');

    return redirect()->back();
}

CanReceiveRatings Trait

Getting all ratings:

ratingsReceived() - morphMany to Ratings

Getting overall (average) rating:

getOverallRating() 

CanGiveRatings Trait

Getting ratings given by this:

ratingsGiven() - hasMany to Ratings

Giving a rating:

rate(RatingReceivable $ratable, $ratingValue)

Rating

You can change rater function in Rating model if you want something other than App\User to give ratings.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固