<?php

    namespace Modules\Lpj\Models;

    use Illuminate\Database\Eloquent\Factories\HasFactory;
    use Illuminate\Database\Eloquent\Model;
    use Illuminate\Database\Eloquent\SoftDeletes;
    use Modules\Usermanagement\Models\User;

    class PermohonanPembatalan extends Base
    {

        protected $table = 'permohonan_pembatalan';

        protected $fillable = [
            'permohonan_id',
            'alasan_pembatalan',
            'file_pembatalan',
            'status',
            'keterangan',
            'authorized_at',
            'authorized_status',
            'created_by',
            'updated_by',
            'deleted_by',
            'authorized_by',
        ];

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

        protected $casts = [
            'authorized_status' => 'string',
        ];

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

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

        public function authorizedUser(){
            return $this->belongsTo(User::class, 'authorized_by');
        }
    }
