1 | <?php |
||||
2 | |||||
3 | declare(strict_types=1); |
||||
4 | |||||
5 | namespace MichaelRubel\Couponables\Models\Traits; |
||||
6 | |||||
7 | use Illuminate\Database\Eloquent\Model; |
||||
8 | use Illuminate\Database\Eloquent\Relations\HasMany; |
||||
9 | use Illuminate\Database\Eloquent\Relations\MorphTo; |
||||
10 | use MichaelRubel\Couponables\Models\Contracts\CouponPivotContract; |
||||
11 | |||||
12 | trait DefinesModelRelations |
||||
13 | { |
||||
14 | /** |
||||
15 | * Fetch the latest couponables - redeemed coupon records. |
||||
16 | * |
||||
17 | * @return HasMany |
||||
18 | */ |
||||
19 | 3 | public function couponables(): HasMany |
|||
20 | { |
||||
21 | 3 | $pivot = app(CouponPivotContract::class); |
|||
22 | |||||
23 | 3 | return $this |
|||
24 | 3 | ->hasMany($pivot::class) |
|||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
25 | 3 | ->orderBy($pivot->getRedeemedAtColumn(), 'desc'); |
|||
26 | } |
||||
27 | |||||
28 | /** |
||||
29 | * The only model allowed to redeem the coupon. |
||||
30 | * |
||||
31 | * @return MorphTo |
||||
32 | */ |
||||
33 | 8 | public function redeemer(): MorphTo |
|||
34 | { |
||||
35 | 8 | return $this->morphTo(); |
|||
0 ignored issues
–
show
It seems like
morphTo() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
36 | } |
||||
37 | } |
||||
38 |