'integer', ]; protected $appends = [ 'unlocked', ]; protected function unlocked(): Attribute { return Attribute::make( get: function () { if (!$this->achievement) return false; if (!$this->achievement->progressive || !$this->achievement->threshold) return true; return ($this->progress ?? 0) >= $this->achievement->threshold; } ); } // --------------------------------------------------------------- // Relationships // --------------------------------------------------------------- public function user(): BelongsTo { return $this->belongsTo(User::class); } public function achievement(): BelongsTo { return $this->belongsTo(Achievement::class); } }