Skip to content

Commit 009b64b

Browse files
committed
feat: LAR-188 update GamifyProvider path
1 parent 70ec525 commit 009b64b

File tree

4 files changed

+33
-20
lines changed

4 files changed

+33
-20
lines changed

app-modules/gamify/src/Models/Reputation.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Laravelcm\Gamify\Models;
66

7+
use App\Models\User;
78
use Carbon\Carbon;
89
use Illuminate\Database\Eloquent\Model;
910
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -12,7 +13,7 @@
1213
/**
1314
* @property-read int $id
1415
* @property-read int $point
15-
* @property-read Model payee
16+
* @property-read User payee
1617
* @property-read Carbon $created_at
1718
* @property-read Carbon $updated_at
1819
*/
@@ -21,7 +22,7 @@ final class Reputation extends Model
2122
protected $guarded = [];
2223

2324
/**
24-
* @return BelongsTo<Model, $this>
25+
* @return BelongsTo<User, $this>
2526
*/
2627
public function payee(): BelongsTo
2728
{

app-modules/gamify/src/PointType.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace Laravelcm\Gamify;
66

7+
use App\Models\User;
78
use Illuminate\Database\Eloquent\Model;
89
use Illuminate\Database\Eloquent\Relations\HasMany;
9-
use Illuminate\Database\Query\Builder;
1010
use Laravelcm\Gamify\Exceptions\InvalidPayeeModelException;
1111
use Laravelcm\Gamify\Exceptions\PointsNotDefinedException;
1212
use Laravelcm\Gamify\Exceptions\PointSubjectNotSetException;
@@ -32,9 +32,11 @@ public function qualifier(): bool
3232
}
3333

3434
/**
35-
* Payee who will be recieving points
35+
* Payee who will be receiving points
3636
*
3737
* @return Model
38+
* @throws PointSubjectNotSetException
39+
* @throws InvalidPayeeModelException
3840
*/
3941
public function payee(): Model
4042
{
@@ -49,6 +51,7 @@ public function payee(): Model
4951
* Subject model for point
5052
*
5153
* @return Model
54+
* @throws PointSubjectNotSetException
5255
*/
5356
public function getSubject(): Model
5457
{
@@ -103,6 +106,7 @@ public function setSubject(mixed $subject): void
103106
* @return bool
104107
*
105108
* @throws InvalidPayeeModelException
109+
* @throws PointSubjectNotSetException
106110
*/
107111
public function reputationExists(): bool
108112
{
@@ -115,6 +119,7 @@ public function reputationExists(): bool
115119
* @return Model
116120
*
117121
* @throws InvalidPayeeModelException
122+
* @throws PointSubjectNotSetException
118123
*/
119124
public function firstReputation(): Model
120125
{
@@ -124,10 +129,12 @@ public function firstReputation(): Model
124129
/**
125130
* Store a reputation in the database
126131
*
127-
* @param array $meta
132+
* @param array $meta
128133
* @return mixed
129134
*
130135
* @throws InvalidPayeeModelException
136+
* @throws PointSubjectNotSetException
137+
* @throws PointsNotDefinedException
131138
*/
132139
public function storeReputation(array $meta): Reputation
133140
{
@@ -162,9 +169,10 @@ public function reputationQuery(): HasMany
162169
/**
163170
* Return reputations payee relation
164171
*
165-
* @return HasMany
172+
* @return HasMany<User>
166173
*
167174
* @throws InvalidPayeeModelException
175+
* @throws PointSubjectNotSetException
168176
*/
169177
protected function payeeReputations(): HasMany
170178
{

app-modules/gamify/src/Providers/GamifyServiceProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ final class GamifyServiceProvider extends ServiceProvider
1111
{
1212
public function register(): void
1313
{
14-
$this->mergeConfigFrom(base_path('app-modules/gamify/config/gamify.php'), 'gamify');
14+
$this->mergeConfigFrom(__DIR__.'/../../config/gamify.php', 'gamify');
1515
}
1616

1717
public function boot(): void
1818
{
1919
$this->publishes([
20-
base_path('app-modules/gamify/config/gamify.php') => config_path('gamify.php'),
20+
__DIR__.'/../../config/gamify.php' => config_path('gamify.php'),
2121
], 'gamify-config');
2222

23-
$this->loadMigrationsFrom(base_path('app-modules/gamify/database/migrations'));
23+
$this->loadMigrationsFrom(__DIR__.'/../../database/migrations');
2424

2525
if ($this->app->runningInConsole()) {
2626
$this->commands([

app-modules/gamify/src/Traits/HasReputations.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44

55
namespace Laravelcm\Gamify\Traits;
66

7+
use App\Models\User;
78
use Illuminate\Database\Eloquent\Collection;
89
use Illuminate\Database\Eloquent\Relations\HasMany;
910
use Illuminate\Support\Str;
11+
use Laravelcm\Gamify\Exceptions\InvalidPayeeModelException;
12+
use Laravelcm\Gamify\Exceptions\PointsNotDefinedException;
13+
use Laravelcm\Gamify\Exceptions\PointSubjectNotSetException;
1014
use Laravelcm\Gamify\Models\Reputation;
1115
use Laravelcm\Gamify\PointType;
1216

@@ -18,8 +22,6 @@ trait HasReputations
1822
{
1923
/**
2024
* Give reputation point to payee
21-
*
22-
* @return bool
2325
*/
2426
public function givePoint(PointType $pointType): bool
2527
{
@@ -35,7 +37,7 @@ public function givePoint(PointType $pointType): bool
3537
/**
3638
* Undo last given point for a subject model
3739
*
38-
* @return bool
40+
* @throws InvalidPayeeModelException
3941
*/
4042
public function undoPoint(PointType $pointType): bool
4143
{
@@ -51,8 +53,6 @@ public function undoPoint(PointType $pointType): bool
5153

5254
/**
5355
* Reputations of user relation
54-
*
55-
* @return HasMany
5656
*/
5757
public function reputations(): HasMany
5858
{
@@ -63,8 +63,12 @@ public function reputations(): HasMany
6363
* Store a reputation for point
6464
*
6565
* @return mixed
66+
*
67+
* @throws InvalidPayeeModelException
68+
* @throws PointSubjectNotSetException
69+
* @throws PointsNotDefinedException
6670
*/
67-
public function storeReputation(PointType $pointType, array $meta = [])
71+
public function storeReputation(PointType $pointType, array $meta = []): bool
6872
{
6973
if (! $this->isDuplicatePointAllowed($pointType) && $pointType->reputationExists()) {
7074
return false;
@@ -104,7 +108,7 @@ public function reducePoint($point = 1)
104108
*
105109
* @return mixed
106110
*/
107-
public function resetPoint()
111+
public function resetPoint(): mixed
108112
{
109113
$this->forceFill([$this->getReputationField() => 0])->save();
110114

@@ -114,10 +118,10 @@ public function resetPoint()
114118
/**
115119
* Get user reputation point
116120
*
117-
* @param bool $formatted
121+
* @param bool $formatted
118122
* @return int|string
119123
*/
120-
public function getPoints($formatted = false)
124+
public function getPoints(bool $formatted = false): int|string
121125
{
122126
$point = $this->{$this->getReputationField()};
123127

@@ -133,7 +137,7 @@ public function getPoints($formatted = false)
133137
*
134138
* @return string
135139
*/
136-
protected function getReputationField()
140+
protected function getReputationField(): string
137141
{
138142
return property_exists($this, 'reputationColumn')
139143
? $this->reputationColumn
@@ -145,7 +149,7 @@ protected function getReputationField()
145149
*
146150
* @return bool
147151
*/
148-
protected function isDuplicatePointAllowed(PointType $pointType)
152+
protected function isDuplicatePointAllowed(PointType $pointType): bool
149153
{
150154
return property_exists($pointType, 'allowDuplicates')
151155
? $pointType->allowDuplicates

0 commit comments

Comments
 (0)