New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

binafy/laravel-score

Laravel Score is a lightweight and flexible package for adding scoring functionality to any Eloquent model in a Laravel application
1,004 13
Install
composer require binafy/laravel-score
Latest Version:v1.1.0
PHP:^8.0
Laravel:9 – 13
License:MIT
Last Updated:Apr 23, 2026
Links: GitHub  ·  Packagist
Maintainer: binafy

Laravel Score

laravel-score

PHP Version Require Latest Stable Version Total Downloads License Passed Tests Ask DeepWiki

Introduction

A comprehensive Laravel package to implement scoring systems effortlessly. Whether you're building leaderboards, calculating performance metrics, or managing gamification features, Laravel Score provides an intuitive API to define, calculate, and manage scores seamlessly. Perfect for applications requiring dynamic and flexible scoring mechanisms.

Key Features:

  • Simple integration with Eloquent models.
  • Support for customizable scoring rules.
  • Designed for performance and scalability.
  • Extensible and developer-friendly.

Installation

You can install the package with Composer.

composer require binafy/laravel-score

Publish

If you want to publish a config file you can use this command:

php artisan vendor:publish --tag="laravel-score-config"

If you want to publish the migrations you can use this command:

php artisan vendor:publish --tag="laravel-score-migrations"

For convenience, you can use this command to publish config, migration, and ... files:

php artisan vendor:publish --provider="Binafy\LaravelScore\Providers\LaravelScoreServiceProvider"

After publishing, run the php artisan migrate command.

Usage

To enable scoring functionality, you need to use two traits:

On the model giving the score (e.g. User):

use Binafy\LaravelScore\Traits\InteractWithScore;
use \Illuminate\Database\Eloquent\Model;

class User extends Model
{
    use InteractWithScore;
}

On the model receiving the score (e.g. Photo):

use Binafy\LaravelScore\Traits\Scoreable;
use Illuminate\Database\Eloquent\Model;

class Photo extends Model
{
    use Scoreable;
}

Add Score

To give a positive score to a scoreable model:

$user->addScore(
    Model $scoreable,
    int $score = 1,
    int|null $userId = null
);

Add Negative Score

To assign a negative score:

$user->addNegativeScore(
    Model $scoreable,
    int|null $userId = null
);

Checking Scores

You can check whether a model has already been scored by a specific user:

$user->hasScored(
    Model $scoreable,
    int|null $userId = null
): bool;

$photo->isScored(
    ?int $userId = null
): bool;

Count Scores

To get the total number of scores for a model:

$photo->getScoresCount(): int;

Delete score

To remove an existing score:

$user->removeScore(Model $scoreable): bool;

$photo->removeScore(?int $userId = null): bool;

Contributors

Thanks to all the people who contributed. Contributors.

Security

If you discover any security-related issues, please email binafy23@gmail.com instead of using the issue tracker.

Changelog

The changelog can be found in the CHANGELOG.md file of the GitHub repository. It lists the changes, bug fixes, and improvements made to each version of the Laravel User Monitoring package.

License

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

Star History

Star History Chart

Donate

If this package is helpful for you, you can buy a coffee for me :) ❤️

Related Packages

lastdragon-ru/lara-asp-eloquent

Contains useful extensions and mixins for Eloquent.

150,070 1
binafy/laravel-discount

The Laravel-Discount is a Laravel package designed to handle discounts in your a...

1,664 58
imanghafoori/laravel-nullable

A package to help you write expressive defensive code in a functional manner

564,170 151

Version History

Version Released PHP Laravel License
v1.1.0 ^8.0 ^9.0|^10.0|^11.0|^12.0|^13.0 MIT
v1.0.0 ^8.0 ^9.0|^10.0|^11.0|^12.0 MIT
v0.9.5 ^8.0 ^9.0|^10.0|^11.0|^12.0 MIT
v0.9.4 ^8.0 ^9.0|^10.0|^11.0|^12.0 MIT
v0.9.3 ^8.0 ^9.0|^10.0|^11.0|^12.0 MIT