Download the PHP package jobmetric/laravel-star without Composer
On this page you can find all versions of the php package jobmetric/laravel-star. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jobmetric/laravel-star
More information about jobmetric/laravel-star
Files in jobmetric/laravel-star
Package laravel-star
Short Description This is a star rating management package for any object in Laravel that you can use in your projects.
License MIT
Homepage https://doc.jobmetric.net/package/laravel-star
Informations about the package laravel-star
Laravel Star
A modern, flexible, and test-covered Laravel package that allows your models to handle star rating functionality (e.g., 1 to 5 stars).
This package provides a clean API for both starable (e.g., articles, posts) and starrer (e.g., users, devices) models.
💾 Installation
Install via composer:
Then publish and run the migration:
✨ Usage
Step 1: Add HasStar
to your starable model (e.g., Article
)
Step 2: Add CanStar
to your starrer model (e.g., User
)
✅ Main Features
Add or Update a Star Rating
You can also pass extra options like device ID:
Remove a Star Rating
Check if a Star Exists
Get Star Count and Average
Get Summary
Get Latest Stars
Forget Stars (All for a user or device)
🎯 Conditional Methods
Rating Checks
Get Rated Value
📦 CanStar Feature Set
Check if a model has starred something
Get rate value
Remove star from a model
Count by Rate or Total
Summary of Ratings Given
Models that user has starred
Stars to specific model type
Latest Stars Given
🧱 Star Model Columns
Field | Description |
---|---|
starable_type | Polymorphic class of starable (e.g., Post) |
starable_id | ID of the starable model |
starred_by_type | Polymorphic class of starrer (e.g., User) |
starred_by_id | ID of the starrer |
rate | Star rating (e.g., 1 to 5) |
ip | IP address of the request |
device_id | Optional device identifier |
source | Source of the request (e.g., web, app, api) |
created_at | Timestamp when the star was created |
updated_at | Timestamp when the star was last updated |
🧪 Events
Event | Triggered When |
---|---|
StarAddEvent | A new star is created and saved |
StarRemovingEvent | A star is about to be deleted |
StarRemovedEvent | A star has been successfully deleted |
StarUpdatingEvent | A star is about to be updated |
StarUpdatedEvent | A star has been successfully updated |
Contributing
Thank you for considering contributing to the Laravel Star! The contribution guide can be found in the CONTRIBUTING.md.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-star with dependencies
laravel/framework Version >=9.19
jobmetric/laravel-package-core Version ^1.7