<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class ImportTemplate extends Model
{
    use HasFactory;

    protected $fillable = [
        'uuid', 'name', 'description', 'source_type', 'default_record_type', 'sample_headers', 'user_id', 'client_id', 'is_active', 'reactivate', 'meta',
    ];

    protected $casts = [
        'sample_headers' => 'array',
        'meta' => 'array',
        'is_active' => 'boolean',
        'reactivate' => 'boolean',
    ];

    public function getRouteKeyName(): string
    {
        return 'uuid';
    }

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

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

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