<?php

namespace App\Models;

use App\Enums\JenisPengaduan;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Pengaduan extends Model
{
    use HasFactory;
    protected $table = 'pengaduan_bks';

    protected $primaryKey = 'id_pengaduan_bk';

    protected $fillable = [
        'tanggal',
        'jenis_pengaduan',
        'judul_pengaduan',
        'metode',
        'isi_keluhan',
        'id_user',
        'dokumentasi',
        'status',
    ];

    protected $casts = [
        'jenis_pengaduan' => JenisPengaduan::class,
    ];

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

    public function riwayat()
    {
        return $this->hasMany(Riwayat::class, 'id_pengaduan_bk');
    }
}
