<?php

namespace App\Models;

class MarketerModel extends BaseCompanyModel
{
    protected $table = 'marketers';
    protected $primaryKey = 'id';
    protected $useTimestamps = true;
    protected $allowedFields = ['company_id', 'name', 'email', 'phone', 'commission_type', 'commission_value', 'is_active'];

    public function calculateCommission(array $marketer, float $invoiceAmount): float
    {
        return $marketer['commission_type'] === 'percentage'
            ? round($invoiceAmount * ((float) $marketer['commission_value'] / 100), 2)
            : (float) $marketer['commission_value'];
    }
}
