<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class UserAchievement extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = ['user_id', 'reward_badge_id', 'awarded_date', 'reason'];

    protected function casts(): array
    {
        return ['awarded_date' => 'date'];
    }

    public function user(): BelongsTo { return $this->belongsTo(User::class); }
    public function badge(): BelongsTo { return $this->belongsTo(RewardBadge::class, 'reward_badge_id'); }
}
