PHPackages                             alhawari/rateify - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. alhawari/rateify

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

alhawari/rateify
================

A simple Laravel package for adding rating functionality (1–5 stars) to any model.

v1.0.1(7mo ago)11MITPHPPHP &gt;=8.0

Since Nov 12Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/alhawari-abdalla/Rateify)[ Packagist](https://packagist.org/packages/alhawari/rateify)[ RSS](/packages/alhawari-rateify/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

⭐ Rateify — Laravel Rating System
=================================

[](#-rateify--laravel-rating-system)

[![Latest Version](https://camo.githubusercontent.com/ae38ed47a9cc9bd87c497ade3828b6b23347b98afa85fdc98eb4f7483f8e0c91/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c6861776172692f726174656966792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alhawari/rateify)[![Total Downloads](https://camo.githubusercontent.com/90a451cd37e89df2e58d49f004d4ed7f3f84e34720681d6310457edba26327d1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c6861776172692f726174656966792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alhawari/rateify)[![License](https://camo.githubusercontent.com/107ce4873558c699fae91b3602f56a5685ec08b4a491803dbc595924a089ed02/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f616c6861776172692d636f64652f72617465696679)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/35f4fac92aa267c2e5a0778df9fa054b74d372a90a2c24471e16c3f1c1e9c2a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f616c6861776172692f72617465696679)](https://php.net/)[![Laravel Version](https://camo.githubusercontent.com/fd033388b15c33b8999c2f4274ea1319423e9e556954817980b94cdc29caa99d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d382e78253230746f25323031302e782d6f72616e6765)](https://laravel.com/)

A robust, flexible, and easy-to-use Laravel package for adding star ratings (1-5) to any Eloquent model. Perfect for product reviews, content ratings, and user feedback systems.

✨ Features
----------

[](#-features)

- Rate any Eloquent model
- Support for rating comments
- Prevent duplicate ratings
- Calculate average ratings
- Get rating counts
- Check if a user has rated an item
- Remove ratings
- Fully customizable (min/max rating values)
- RESTful API endpoints
- Secure with built-in authentication
- Comprehensive validation
- Well-documented code

🚀 Installation
--------------

[](#-installation)

1. Install the package via Composer:

```
composer require alhawari/rateify
```

2. Publish the configuration file (optional):

```
php artisan vendor:publish --provider="Alhawari\\Rateify\\RateifyServiceProvider" --tag=config
```

3. Publish and run the migrations:

```
php artisan vendor:publish --provider="Alhawari\\Rateify\\RateifyServiceProvider" --tag=migrations
php artisan migrate
```

⚙️ Configuration
----------------

[](#️-configuration)

The configuration file allows you to customize the rating system:

```
return [
    'max_rating' => 5,  // Maximum rating value
    'min_rating' => 1,  // Minimum rating value
];
```

🛠 Usage
-------

[](#-usage)

### 1. Add the Rateable Trait to Your Model

[](#1-add-the-rateable-trait-to-your-model)

```
use Alhawari\Rateify\Traits\Rateable;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    use Rateable;

    // Optional: Add custom logic to control who can rate
    public function canBeRated($userId): bool
    {
        return $this->user_id !== $userId; // Prevent users from rating their own posts
    }
}
```

### 2. Basic Usage

[](#2-basic-usage)

```
// Get the average rating
$averageRating = $post->averageRating();

// Get the number of ratings
$ratingCount = $post->ratingsCount();

// Check if a user has rated the post
$hasRated = $post->isRatedBy($userId);

// Get a user's rating
$userRating = $post->getUserRating($userId);

// Rate a post
$rating = $post->rate($userId, 5, 'Great post!');

// Rate using the authenticated user
$rating = $post->rateByUser(4, 'Nice!');

// Remove a rating
$removed = $post->removeRating($userId);
```

🌐 API Endpoints
---------------

[](#-api-endpoints)

### Rate or Update a Rating

[](#rate-or-update-a-rating)

```
POST /rateify/rate
```

**Parameters:**

ParameterTypeRequiredDescriptionmodelstringYesFully qualified model classidintYesID of the model to ratevalueintYesRating value (1-5)commentstringNoOptional comment with the rating**Example Response:**

```
{
    "success": true,
    "message": "Rating saved successfully.",
    "data": {
        "rating": 5,
        "comment": "Great post!",
        "average": 4.5,
        "count": 10,
        "user_rating": 5
    }
}
```

### Remove a Rating

[](#remove-a-rating)

```
DELETE /rateify/rate
```

**Parameters:**

ParameterTypeRequiredDescriptionmodelstringYesFully qualified model classidintYesID of the model🔒 Permissions
-------------

[](#-permissions)

By default, all API endpoints are protected by the `auth` middleware, so only authenticated users can rate items.

🧪 Testing
---------

[](#-testing)

```
composer test
```

🤝 Contributing
--------------

[](#-contributing)

Please see contact at  .

🔐 Security
----------

[](#-security)

If you discover any security related issues, please email  or use issue tracker.

📝 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

📚 Credits
---------

[](#-credits)

- [Your Name](https://github.com/alhawari-abdalla)
- [All Contributors](../../contributors)

---

⭐ If you find this package useful, please consider giving it a star on [GitHub](https://github.com/alhawari-abdalla/rateify).

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance62

Regular maintenance activity

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

233d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/209245823?v=4)[Alhawari Code](/maintainers/alhawari-abdalla)[@alhawari-abdalla](https://github.com/alhawari-abdalla)

---

Top Contributors

[![alhawari-abdalla](https://avatars.githubusercontent.com/u/209245823?v=4)](https://github.com/alhawari-abdalla "alhawari-abdalla (6 commits)")

### Embed Badge

![Health badge](/badges/alhawari-rateify/health.svg)

```
[![Health](https://phpackages.com/badges/alhawari-rateify/health.svg)](https://phpackages.com/packages/alhawari-rateify)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[illuminate/pagination

The Illuminate Pagination package.

12234.1M1.0k](/packages/illuminate-pagination)[illuminate/pipeline

The Illuminate Pipeline package.

9349.2M282](/packages/illuminate-pipeline)[illuminate/redis

The Illuminate Redis package.

8314.6M375](/packages/illuminate-redis)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
