Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
66.67% |
6 / 9 |
|
25.00% |
1 / 4 |
CRAP | |
0.00% |
0 / 1 |
| GamificationAchievement | |
66.67% |
6 / 9 |
|
25.00% |
1 / 4 |
4.59 | |
0.00% |
0 / 1 |
| casts | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| influencer | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| badge | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| rule | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 6 | use Illuminate\Database\Eloquent\Model; |
| 7 | use Illuminate\Database\Eloquent\Relations\BelongsTo; |
| 8 | |
| 9 | class GamificationAchievement extends Model |
| 10 | { |
| 11 | use HasFactory; |
| 12 | |
| 13 | protected $fillable = [ |
| 14 | 'tenant_id', 'store_id', 'influencer_id', 'badge_id', 'gamification_rule_id', |
| 15 | 'period_year', 'period_month', 'achieved_value', 'bonus_percentage', 'achieved_at', 'metadata', |
| 16 | ]; |
| 17 | |
| 18 | protected function casts(): array |
| 19 | { |
| 20 | return [ |
| 21 | 'achieved_value' => 'decimal:2', |
| 22 | 'bonus_percentage' => 'decimal:2', |
| 23 | 'achieved_at' => 'datetime', |
| 24 | 'metadata' => 'array', |
| 25 | ]; |
| 26 | } |
| 27 | |
| 28 | public function influencer(): BelongsTo { return $this->belongsTo(Influencer::class); } |
| 29 | public function badge(): BelongsTo { return $this->belongsTo(Badge::class); } |
| 30 | public function rule(): BelongsTo { return $this->belongsTo(GamificationRule::class, 'gamification_rule_id'); } |
| 31 | } |