<?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 FusionType extends Model
{
    use SoftDeletes, MultiTenantModelTrait, Auditable, HasFactory;

    public $table = 'fusion_types';

    public static $searchable = [
        'name',
    ];

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

    protected $fillable = [
        'name',
        'fusioncategory_id',
        'parent_name_id',
        'created_at',
        'updated_at',
        'deleted_at',
        'team_id',
    ];

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

    public function statusAssets()
    {
        return $this->hasMany(Asset::class, 'status_id', 'id');
    }

    public function commissionTypeCommissionDatas()
    {
        return $this->hasMany(CommissionData::class, 'commission_type_id', 'id');
    }

    public function checklistStatusFusionTypes1ChecklistReports()
    {
        return $this->hasMany(ChecklistReport::class, 'checklist_status_fusion_types_1_id', 'id');
    }

    public function checklistStatusFusionTypes2ChecklistReports()
    {
        return $this->hasMany(ChecklistReport::class, 'checklist_status_fusion_types_2_id', 'id');
    }

    public function commissionValueFusionTypes1CommissionDatas()
    {
        return $this->hasMany(CommissionData::class, 'commission_value_fusion_types_1_id', 'id');
    }

    public function commissionValueFusionTypes2CommissionDatas()
    {
        return $this->hasMany(CommissionData::class, 'commission_value_fusion_types_2_id', 'id');
    }

    public function fusioncategory()
    {
        return $this->belongsTo(FusionCategory::class, 'fusioncategory_id');
    }

    public function parent_name()
    {
        return $this->belongsTo(self::class, 'parent_name_id');
    }

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