PHPackages                             larastash/reviews - 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. [Database &amp; ORM](/categories/database)
4. /
5. larastash/reviews

ActiveLibrary[Database &amp; ORM](/categories/database)

larastash/reviews
=================

Eloquent model reviews for Laravel.

1.0.0(2y ago)010MITPHPPHP ^8.1

Since Jul 18Pushed 2y ago1 watchersCompare

[ Source](https://github.com/larastash/reviews)[ Packagist](https://packagist.org/packages/larastash/reviews)[ Docs](https://github.com/larastash/reviews)[ RSS](/packages/larastash-reviews/feed)WikiDiscussions master Synced 1mo ago

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

💬⭐ Laravel Reviews
==================

[](#-laravel-reviews)

The Larastash Reviews package is a powerful Laravel package that enables you to add review functionalities to your Eloquent models.

With this package, you can easily manage reviews for various reviewable entities and perform various review-related operations.

Requirements
------------

[](#requirements)

- Laravel ^10;
- PHP ^8.1;

Installation
------------

[](#installation)

To install the Larastash Reviews package, you can use Composer:

```
composer require larastash/reviews
```

After installing the package, publish migration and config files:

```
php artisan vendor:publish --tag="larastash:reviews"
```

> **Note** You can edit migration and set `foreignUuid` if your user model uses a UUID.

Prepare Models
--------------

[](#prepare-models)

To use the Larastash Reviews package, you need to apply the [`Reviewable`](src/Concerns/Reviewable.php) trait to the Eloquent model that you want to make reviewable.

```
namespace App\Models;

...
use Larastash\Reviews\Concerns\Reviewable;

class Product extends Model
{
    use Reviewable;

    ...
}
```

Additionally, you can apply the [`Reviewer`](src/Concerns/Reviewer.php) trait to the User model.

```
namespace App\Models;

...
use Larastash\Reviews\Concerns\Reviewer;

class User extends Model
{
    use Reviewer;

    ...
}
```

Usage
-----

[](#usage)

The following examples demonstrate the usage of the Laravel package for managing reviews.

```
review($product)
$product->review();
```

- `review($product)`: Creates a new `Larastash\Reviews\Review` instance for the given `$product`. It returns a `Larastash\Reviews\Review` instance.
- `$product->review()`: An alternative way to create a new `Larastash\Reviews\Review` instance for the given `$product`. It also returns a `Larastash\Reviews\Review` instance.

Creates or updates a review for the `$product` entity with the provided values. The parameters `$value`, `$body`, `$title`, `$extra`, and `$userId` are used to set the properties of the review.

```
$product->review($value, $body, $title, $extra, $userId);
```

### Publish Reviews

[](#publish-reviews)

To create a new review (uses `updateOrCreate` under the hood), use the `publish` method.

```
review($product)->publish(5); // only value
review($product)->publish(5, 'I love it!'); // value & body
review($product)->publish(5, 'I love it!', 'Awesome'); // value, body & title
review($product)->publish(5, title: 'Awesome'); // value & title
```

### With Extra Data

[](#with-extra-data)

You can pass additional data to the review, such as approved, anonymous review, recommended, etc.

```
review($product)->extra(['approved' => false, 'recommended' => 1])->publish(5);
```

```
review($product)->with('approved', false)->with('recommended', 1)->publish(5);
```

> **Note** You can also work with this data, for example, choose an average extra value or get only approved reviews.

### Another User (Reviewer)

[](#another-user-reviewer)

Publish review as another user.

```
review($product)->as(User::find(1337))->publish(5);
review($product)->as(1337)->publish(5);
```

> **Note** By default, the overview is owned by the current authorized user (by `Auth::id()`).

### Update Review

[](#update-review)

Sometimes, when we have some extra data, for example, we need to change only `approved`, then we can use the `update` method.

```
review($product)->with('approved', true)->update(5);
```

```
review($product)->by(User::find(1337))->with('approved', true)->update(5);
review($product)->by(1337)->with('approved', true)->update(5);
```

It will change the value `approved` to `true`, and will not affect other extra data, such as `recommended`.

Of course, you can use the `publish` method to update the review. But then you will need to pass the full current extra data, not just the `approved = true`.

### User Has Review

[](#user-has-review)

Check if the user has a review or not.

```
review($product)->exists();
```

```
review($product)->by(User::find(1337))->exists();
review($product)->by(1337)->exists();
```

### Delete Review

[](#delete-review)

Deletes the user's review.

```
review($product)->delete();
```

```
review($product)->by(User::find(1337))->delete();
review($product)->by(1337)->delete();
```

### Total Number of Reviews

[](#total-number-of-reviews)

Get the total number of reviews for a entry.

```
review($product)->total();
```

### Avg Value and Extras

[](#avg-value-and-extras)

Get the average value of a review.

```
review($product)->avg();
review($product)->avg(precision: 0); // 2 by default
```

Get the average extra value of a review.

```
review($product)->avg('recommended');
review($product)->avg('recommended', 0); // precision is 2 by default
```

### Reviewable Query Builder

[](#reviewable-query-builder)

Get the review query builder instance.

```
review($product)->query()->doSomething();
```

### Eager Loading

[](#eager-loading)

```
$product = Product::with('reviews');
```

### Related Reviewable Methods

[](#related-reviewable-methods)

```
$product = Product::withReviewAvgValue();
$product->reviews_avg_value;
```

```
Product::orderByReviewValue();
```

```
Product::orderByReviewValueDesc();
```

```
$product = Product::withReviewAvgExtra('recommended')->first();
$product->reviews_avg_extra_recommended;
```

```
Product::orderByReviewExtra('recommended');
```

```
Product::orderByReviewExtraDesc('recommended');
```

```
use App\Models\Product;
use Larastash\Reviews\Models\Review;

Review::withType(Product::class)->count();
```

### Get User Reviews

[](#get-user-reviews)

This will be available if you add the `Larastash\Reviews\Concerns\Reviewer` trait to the `User` model.

```
auth()->user()->reviews;
```

Helpers
-------

[](#helpers)

### `review()`

[](#review)

This function, `review`, is a helper function provided by the Laravel package.

It creates a new `Larastash\Reviews\Review` instance for the given reviewable entity (a model that uses the `Reviewable` trait). This function is particularly useful when you want to interact with the review-related methods of the `Review` class for a specific model instance. It saves you from manually creating a new `Review` instance each time you want to perform actions related to reviews for a specific entity.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

If you find any issues or have suggestions for improvement, please feel free to contribute by creating a pull request or submitting an issue.

Credits
-------

[](#credits)

- [chipslays](https://github.com/chipslays)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Unknown

Total

1

Last Release

1033d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/19103498?v=4)[chipslays](/maintainers/chipslays)[@chipslays](https://github.com/chipslays)

---

Top Contributors

[![chipslays](https://avatars.githubusercontent.com/u/19103498?v=4)](https://github.com/chipslays "chipslays (7 commits)")

---

Tags

eloquentlaravellaravel-reviewablelaravel-reviewsreviewablereviewslaravelmodeleloquentreviewsreviewablelaravel-reviewablelaravel-reviews

### Embed Badge

![Health badge](/badges/larastash-reviews/health.svg)

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

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591444.8k2](/packages/spiritix-lada-cache)[pdphilip/elasticsearch

An Elasticsearch implementation of Laravel's Eloquent ORM

145360.2k4](/packages/pdphilip-elasticsearch)[shiftonelabs/laravel-cascade-deletes

Adds application level cascading deletes to Eloquent Models.

163632.1k2](/packages/shiftonelabs-laravel-cascade-deletes)

PHPackages © 2026

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