<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ResellerProfile extends Model
{
    protected $fillable = [
        'user_id',
        'reseller_code',
        'custom_link',
        'qr_code_path',
        'commission_preference',
        'total_sales_count',
        'total_commissions_earned',
    ];

    protected $casts = [
        'total_sales_count' => 'integer',
        'total_commissions_earned' => 'decimal:2',
    ];

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

    public function commissions()
    {
        return $this->hasMany(Commission::class);
    }

    public function transactions()
    {
        return $this->hasMany(Transaction::class, 'reseller_id');
    }
}
