| Total Complexity | 2 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class Badge extends Model |
||
| 11 | { |
||
| 12 | use HasFactory; |
||
|
|
|||
| 13 | |||
| 14 | /** |
||
| 15 | * The attributes that are mass assignable. |
||
| 16 | * |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | protected $fillable = [ |
||
| 20 | 'name', |
||
| 21 | 'description', |
||
| 22 | 'icon', |
||
| 23 | 'color', |
||
| 24 | 'type', |
||
| 25 | 'rule' |
||
| 26 | ]; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Get the users that owns the badge. |
||
| 30 | * |
||
| 31 | * @return BelongsTomany |
||
| 32 | */ |
||
| 33 | public function users(): BelongsTomany |
||
| 34 | { |
||
| 35 | return $this->belongsToMany(User::class)->withTrashed(); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Check if the given user has unlocked this badge. |
||
| 40 | * |
||
| 41 | * @param User $user The user to check. |
||
| 42 | * |
||
| 43 | * @return bool |
||
| 44 | */ |
||
| 45 | public function hasUser(User $user): bool |
||
| 50 | } |
||
| 51 | } |
||
| 52 |