<?php

namespace Modules\Lpj\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
// use Modules\Lpj\Database\Factories\NocFactory;

class Noc extends Base
{
    protected $table = 'noc';

    protected $fillable = [
        'permohonan_id',
        'persetujuan_penawaran_id',
        'bukti_bayar',
        'nominal_bayar',
        'status_bayar',
        'tanggal_pembayaran',
        'nominal_penyelesaian',
        'status_penyelesaiaan',
        'tanggal_penyelesaian',
        'bukti_penyelesaian',
        'bukti_ksl',
        'memo_penyelesaian',
        'catatan_noc',
        'status',
        'authorized_status',
        'authorized_at',
        'authorized_by',
    ];

    protected $casts = [
        'nominal_bayar' => 'decimal:2',
        'status_bayar' => 'boolean',
        'tanggal_pembayaran' => 'date',
        'nominal_penyelesaian' => 'decimal:2',
        'status_penyelesaiaan' => 'boolean',
        'tanggal_penyelesaian' => 'date',
        'status' => 'boolean',
        'authorized_status' => 'boolean',
        'authorized_at' => 'datetime',
    ];

    // Relationship with Permohonan
    public function permohonan()
    {
        return $this->belongsTo(Permohonan::class, 'permohonan_id');
    }

    // Relationship with PersetujuanPenawaran
    public function persetujuanPenawaran()
    {
        return $this->belongsTo(PersetujuanPenawaran::class, 'persetujuan_penawaran_id');
    }

    // Relationship with User (for authorized_by)
    public function authorizedBy()
    {
        return $this->belongsTo(User::class, 'authorized_by');
    }
}
