<?php

namespace App\Modules\HR\Recruitment\Models;

use App\Models\User;
use App\Modules\Admin\Tenancy\Traits\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class RecruitmentOfferLetterAttachment extends Model
{
    use BelongsToTenant;
    use SoftDeletes;

    protected $table = 'recruitment_offer_letter_attachments';

    protected $fillable = [
        'tenant_id',
        'offer_letter_id',
        'file_path',
        'original_name',
        'file_size',
        'mime_type',
        'uploaded_by',
    ];

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

    public function offerLetter(): BelongsTo
    {
        return $this->belongsTo(RecruitmentOfferLetter::class, 'offer_letter_id');
    }

    public function uploader(): BelongsTo
    {
        return $this->belongsTo(User::class, 'uploaded_by');
    }
}
