https://github.com/code4mk/lara-rating
Rating system for laravel project
https://github.com/code4mk/lara-rating
0devco code4mk laravel rating-system
Last synced: 10 months ago
JSON representation
Rating system for laravel project
- Host: GitHub
- URL: https://github.com/code4mk/lara-rating
- Owner: code4mk
- Created: 2019-05-10T15:22:48.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-11T02:29:36.000Z (almost 7 years ago)
- Last Synced: 2025-04-08T19:52:41.542Z (11 months ago)
- Topics: 0devco, code4mk, laravel, rating-system
- Language: PHP
- Size: 19.5 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

# Rating system Laravel
Easily setup rating system in your laravel poject
# installation
```bash
composer require code4mk/lara-rating
```
# setup
## 1) vendor publish
```bash
php artisan vendor:publish --provider="Code4mk\LaraRate\LaraRateServiceProvider" --tag=config
php artisan vendor:publish --provider="Code4mk\LaraRate\LaraRateServiceProvider" --tag=migrations
```
## 2) config
* `config/laraRate.php`
```php
"rater_table_name" => "users",
"rater_retrive_columns" =>["id","email"]
```
* `php artisan config:clear`
# method
## `create()`
* `int $productID, int $raterID, int $rate, string $comment`
```php
use Krate;
Krate::create($productID,$userID,$rate,$comment)
```
## `update()`
* `int $productID, int $raterID, int $rate, string $comment`
```php
use Krate;
Krate::update($productID,$raterID,$rate,$comment);
```
## `getRatings()`
* get specific product's rating details
* `int productID`
```php
Krate::getRatings($productID);
```
* output
~ `Krate::getRatings(3)`
```json
[
{
"id": 1,
"product_id": 3,
"rater_id": 3,
"rating": 5,
"comment": "5star",
"created_at": "2019-05-10 16:25:10",
"updated_at": "2019-05-10 16:25:10",
"rater": {
"id": 3,
"email": "maruf@gmail.com"
}
},
{
"id": 2,
"product_id": 3,
"rater_id": 2,
"rating": 2,
"comment": "2star",
"created_at": "2019-05-10 16:26:58",
"updated_at": "2019-05-10 16:26:58",
"rater": {
"id": 2,
"email": "jamal@gmail.com"
}
}
]
```
## `getRatingStat()`
* rating type
* `int productID`
```php
Krate::getRatingStat($productID);
```
* output
~ `Krate::getRatingStat(3)`
```json
{
"rateType": {
"one_star": {
"star": 0,
"percent": 0
},
"two_star": {
"star": 1,
"percent": 50
},
"three_star": {
"star": 0,
"percent": 0
},
"four_star": {
"star": 0,
"percent": 0
},
"five_star": {
"star": 1,
"percent": 50
}
},
"total_rater": 2,
"rating": 4
}
```
## getRaterRatings
* customer/rater/user's rating lists
* `int raterID`
```php
Krate::getRaterRatings($raterID);
```
~ `Krate::getRaterRatings(2)`
```json
[
{
"id": 1,
"product_id": 1,
"rater_id": 1,
"rating": 5,
"comment": "5 star",
"created_at": "2019-05-11 00:55:46",
"updated_at": "2019-05-11 00:55:46",
"product": {
"name": "iphone 10",
"slug": "iphone-10"
}
}
]
```
