File tree 1 file changed +50
-0
lines changed
1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -49,3 +49,53 @@ php artisan vendor:publish --provider="Binafy\LaravelScore\Providers\LaravelScor
49
49
50
50
After publishing, run the ` php artisan migrate ` command.
51
51
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
+
You can’t perform that action at this time.
0 commit comments