'integer', 'completed' => 'boolean', 'claimed' => 'boolean', 'completed_at' => 'datetime', ]; public function user(): BelongsTo { return $this->belongsTo(User::class); } public function challenge(): BelongsTo { return $this->belongsTo(DailyChallenge::class, 'challenge_id'); } public function addProgress(int $amount): bool { if ($this->completed) { return false; } $this->increment('progress', $amount); $this->refresh(); if ($this->progress >= $this->challenge->target && ! $this->completed) { $this->update([ 'completed' => true, 'completed_at' => now(), ]); return true; } return false; } }