<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class TypingJobSubmission extends Model
{
    protected $fillable = [
        'user_id',
        'upline_user_id',
        'upline_name',
        'upline_email',
        'upline_mobile',
        'upline_referral_code',
        'expression',
        'operator',
        'left_operand',
        'right_operand',
        'correct_answer',
        'user_answer',
        'reward_amount',
        'submitted_at',
    ];

    protected function casts(): array
    {
        return [
            'reward_amount' => 'decimal:2',
            'submitted_at' => 'datetime',
        ];
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function uplineUser()
    {
        return $this->belongsTo(User::class, 'upline_user_id');
    }
}
