<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;

class Jurnal extends Model
{
    protected $table = 'jurnal';
    protected $fillable = [
        'user_id', 'tanggal', 'perencanaan_kegiatan', 
        'pelaksanaan_kegiatan', 'status_verifikasi', 'catatan_instruktur'
    ];

    protected $casts = [
        'tanggal' => 'date',
    ];

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

    public function siswa()
    {
        return $this->hasOneThrough(
            SiswaMagang::class,
            User::class,
            'id',
            'id',
            'user_id',
            'id_siswa'
        );
    }
}