| Total Complexity | 2 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 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) |
|
|
|
|||
| 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 |
|
| 36 | } |
||
| 37 | } |
||
| 38 |