Skip to content

Commit 89d6986

Browse files
committed
Update README.md
1 parent 9f8b402 commit 89d6986

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

README.md

+50
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,53 @@ php artisan vendor:publish --provider="Binafy\LaravelScore\Providers\LaravelScor
4949

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

52+
## Usage
53+
54+
First of all, you need to use two traits:
55+
56+
```php
57+
use Binafy\LaravelScore\Traits\InteractWithScore;
58+
use \Illuminate\Database\Eloquent\Model;
59+
60+
class User extends Model
61+
{
62+
use InteractWithScore;
63+
}
64+
```
65+
66+
And your model that want to give score to it:
67+
68+
```php
69+
use Binafy\LaravelScore\Traits\Scoreable;
70+
use Illuminate\Database\Eloquent\Model;
71+
72+
class Photo extends Model
73+
{
74+
use Scoreable;
75+
}
76+
```
77+
78+
### Add Score
79+
80+
For giving a score to scoreable, you can use `addScore()` method:
81+
82+
```php
83+
$user->addScore(
84+
Model $scoreable,
85+
int $score = 1,
86+
int|null $userId = null
87+
);
88+
```
89+
90+
### Add Negative Score
91+
92+
If you want to add negative score to scoreable, you can use `addNegativeScore()` method:
93+
94+
```php
95+
$user->addNegativeScore(
96+
Model $scoreable,
97+
int|null $userId = null
98+
);
99+
```
100+
101+

0 commit comments

Comments
 (0)