<?php

namespace App\Models;

use App\Traits\Auditable;
use App\Traits\MultiTenantModelTrait;
use DateTimeInterface;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class ChecklistReport extends Model
{
    use SoftDeletes, MultiTenantModelTrait, Auditable, HasFactory;

    public $table = 'checklist_reports';

    protected $dates = [
        'created_at',
        'updated_at',
        'deleted_at',
    ];

    protected $fillable = [
        'complaint_id',
        'checklist_name_id',
        'checklist_status',
        'created_at',
        'checklist_value_text_1',
        'checklist_value_text_2',
        'checklist_status_fusion_types_1_id',
        'checklist_status_fusion_types_2_id',
        'updated_at',
        'deleted_at',
        'team_id',
        'remarks'
    ];

    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    public function complaint()
    {
        return $this->belongsTo(ServiceComplaint::class, 'complaint_id');
    }

    public function checklist_name()
    {
        return $this->belongsTo(FusionType::class, 'checklist_name_id');
    }

    public function checklist_status_fusion_types_1()
    {
        return $this->belongsTo(FusionType::class, 'checklist_status_fusion_types_1_id');
    }

    public function checklist_status_fusion_types_2()
    {
        return $this->belongsTo(FusionType::class, 'checklist_status_fusion_types_2_id');
    }

    public function checklist_single_line_remarks()
    {
        return $this->belongsTo(FusionType::class, 'remarks');
    }

    public function team()
    {
        return $this->belongsTo(Team::class, 'team_id');
    }
}
