<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

// [INTEGRATION] Checkout fee configuration — mirrors Flutter FeeConfigModel
class FeeConfig extends Model
{
    use HasUlids, SoftDeletes;

    protected $fillable = [
        'user_id', 'store_id', 'local_id', 'name', 'fee_type',
        'amount', 'amount_type', 'tax_id', 'is_active', 'is_default',
        'device_id', 'sync_version', 'is_deleted',
    ];

    protected $casts = [
        'amount' => 'float',
        'is_active' => 'boolean',
        'is_default' => 'boolean',
        'is_deleted' => 'boolean',
        'sync_version' => 'integer',
    ];

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

    public function orderFees(): HasMany
    {
        return $this->hasMany(OrderFee::class);
    }
}
