<?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\HasManyThrough;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
use Swindon\FilamentHashids\Traits\HasHashid;

class Company extends Model implements HasMedia
{
    use HasFactory, HasHashid, InteractsWithMedia, SoftDeletes;

    protected $guarded = ['id'];

    protected function casts(): array
    {
        return [
            'user_id' => 'integer',
        ];
    }

    public static function dataChangeEntryLabels(): array
    {
        return [
            'name' => 'Nama',
            'email' => 'Alamat Surel',
            'address' => 'Alamat',
            'director_name' => 'Nama Direktur',
            'director_nik' => 'NIK Direktur',
            'director_nik_docs' => 'Dokumen NIK Direktur',
            'deed_incorporation' => 'No. Akta Pendirian',
            'deed_incorporation_docs' => 'Dokumen Akta Pendirian',
            'trade_license' => 'No. SIUP / NIB',
            'trade_license_docs' => 'Dokumen SIUP / NIB',
            'tax_id_number' => 'No. NPWP',
            'tax_id_number_docs' => 'Dokumen NPWP',
            'taxable_enterprise' => 'No. PKP',
            'taxable_enterprise_docs' => 'Dokumen PKP',
            'annual_tax_return' => 'No. SPT Tahunan',
            'annual_tax_return_docs' => 'Dokumen SPT Tahunan',
            'domicile_certificate' => 'No. Suket Domisili',
            'domicile_certificate_docs' => 'Dokumen Suket Domisili',
            'profile' => 'No. Profil Perusahaan',
            'profile_docs' => 'Dokumen Profil Perusahaan',
        ];
    }

    public function dataChangeRequests(): MorphMany
    {
        return $this->morphMany(DataChangeRequest::class, 'entity');
    }

    public function journalists(): HasManyThrough
    {
        return $this->hasManyThrough(Journalist::class, PartnerMedia::class);
    }

    public function partnerMedia(): HasOne
    {
        return $this->hasOne(PartnerMedia::class);
    }

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

    public function verificationRequest(): HasOne
    {
        return $this->hasOne(VerificationRequest::class);
    }
}
