PHP code example of binafy / laravel-score

1. Go to this page and download the library: Download binafy/laravel-score library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

binafy / laravel-score example snippets


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

class User extends Model
{
    use InteractWithScore;
}

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

class Photo extends Model
{
    use Scoreable;
}

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

$user->addNegativeScore(
    Model $scoreable,
    int|null $userId = null
);
shell
php artisan vendor:publish --tag="laravel-score-migrations"
shell
php artisan vendor:publish --provider="Binafy\LaravelScore\Providers\LaravelScoreServiceProvider"