Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| GamificationRule | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| casts | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
| badge | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use App\Enums\GamificationMetric; |
| 6 | use App\Enums\Status; |
| 7 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 8 | use Illuminate\Database\Eloquent\Model; |
| 9 | use Illuminate\Database\Eloquent\Relations\BelongsTo; |
| 10 | |
| 11 | class GamificationRule extends Model |
| 12 | { |
| 13 | use HasFactory; |
| 14 | |
| 15 | protected $fillable = [ |
| 16 | 'tenant_id', 'store_id', 'badge_id', 'name', 'metric', 'threshold_value', 'bonus_percentage', |
| 17 | 'status', 'starts_at', 'ends_at', 'metadata', |
| 18 | ]; |
| 19 | |
| 20 | protected function casts(): array |
| 21 | { |
| 22 | return [ |
| 23 | 'metric' => GamificationMetric::class, |
| 24 | 'threshold_value' => 'decimal:2', |
| 25 | 'bonus_percentage' => 'decimal:2', |
| 26 | 'status' => Status::class, |
| 27 | 'starts_at' => 'date', |
| 28 | 'ends_at' => 'date', |
| 29 | 'metadata' => 'array', |
| 30 | ]; |
| 31 | } |
| 32 | |
| 33 | public function badge(): BelongsTo { return $this->belongsTo(Badge::class); } |
| 34 | } |