<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class PenawaranProject extends Model
{
    use HasFactory;
    protected $table = 'penawaran_projects';

    protected $fillable = [
        'judul_project',
        'bidang_sub_sektor_ekonomi_kreatif',
        'deskripsi_project',
        'jenis_penawaran',
        'audiens',
        'batas_terima_tawaran',
        'kontak',
        'foto_proyek',
        'status',
        'benefit',
        'user_id',
    ];

     // Menggunakan casting untuk kolom tanggal
     protected $casts = [
        'batas_terima_tawaran' => 'date', 
    ];

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

    public function pelatihan()
    {
        return $this->hasOne(PenawaranPelatihan::class);
    }

    public function pendanaan()
    {
        return $this->hasOne(PenawaranPendanaan::class);
    }

    public function riset()
    {
        return $this->hasOne(PenawaranRiset::class);
    }
}
