<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class AccountLawyerMapping extends Model
{
    protected $fillable = [
        'loan_id',
        'customer_name',
        'principal_os_amount',
        'odi_amount',
        'crc_amount',
        'statement_date',
        'statement_amount',
        'assign_date',
        'case_submitted_date',
        'case_registration_via',
        'court_fee',
        'case_filed_date',
        'internal_remarks',
        'is_active',
        'created_by',
        'updated_by',
    ];

    protected $casts = [
        'principal_os_amount' => 'decimal:3',
        'odi_amount'          => 'decimal:3',
        'crc_amount'          => 'decimal:3',
        'statement_date'      => 'date',
        'statement_amount'    => 'decimal:3',
        'assign_date'         => 'date',
        'case_submitted_date' => 'date',
        'court_fee'           => 'decimal:3',
        'case_filed_date'     => 'date',
        'is_active'           => 'boolean',
    ];

    public function lawyers()
    {
        return $this->hasMany(AccountLawyerMappingLawyer::class, 'mapping_id');
    }

    public function creator()
    {
        return $this->belongsTo(User::class, 'created_by');
    }

    public function updater()
    {
        return $this->belongsTo(User::class, 'updated_by');
    }
}
