<?php

namespace App\Models;

use App\Modules\Users\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * @property int $id
 * @property int $inviter_id
 * @property int $invitee_id
 * @property int $inviter_points_awarded
 * @property int $inviter_ai_credits_awarded
 * @property int $invitee_points_awarded
 * @property string $status
 */
class Referral extends Model
{
    protected $fillable = [
        'inviter_id',
        'invitee_id',
        'inviter_points_awarded',
        'inviter_ai_credits_awarded',
        'invitee_points_awarded',
        'status',
    ];

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'inviter_points_awarded' => 'integer',
            'inviter_ai_credits_awarded' => 'integer',
            'invitee_points_awarded' => 'integer',
        ];
    }

    /** @return BelongsTo<User, Referral> */
    public function inviter(): BelongsTo
    {
        return $this->belongsTo(User::class, 'inviter_id');
    }

    /** @return BelongsTo<User, Referral> */
    public function invitee(): BelongsTo
    {
        return $this->belongsTo(User::class, 'invitee_id');
    }
}
