<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;

class Letter extends Model
{
    use HasFactory, HasUuids;

    protected $table = 'letters';
    protected $keyType = 'string';
    public $incrementing = false;

    protected $fillable = [
        'nama_mahasiswa',
        'nomor_induk_mahasiswa',
        'program_studi_mahasiswa',
        'tahun_ajaran',
        'start_date',
        'completion_date',
        'lampiran',
        'is_acceptance',
        'nomor_surat_acceptance',
        'is_completion',
        'nomor_surat_completion',
        'address_to',
        'letter_scope',
    ];

    protected static function boot()
    {
        parent::boot();
        static::creating(function ($model) {
            $model->id = Str::uuid()->toString();
        });
    }

    public function fileUpload()
    {
        return $this->hasOne(FileUpload::class, 'letter_id', 'id');
    }
}
