Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
milwad-dev committed Nov 26, 2024
1 parent 9f8b402 commit 89d6986
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,53 @@ php artisan vendor:publish --provider="Binafy\LaravelScore\Providers\LaravelScor

After publishing, run the `php artisan migrate` command.

## Usage

First of all, you need to use two traits:

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

class User extends Model
{
use InteractWithScore;
}
```

And your model that want to give score to it:

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

class Photo extends Model
{
use Scoreable;
}
```

### Add Score

For giving a score to scoreable, you can use `addScore()` method:

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

### Add Negative Score

If you want to add negative score to scoreable, you can use `addNegativeScore()` method:

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


0 comments on commit 89d6986

Please # to comment.