Files
ilycats/app/Models/MedicalRecord.php
T
2026-09-23 12:45:02 +07:00

42 lines
939 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; // 1. TAMBAHKAN BARIS INI
class MedicalRecord extends Model
{
use HasFactory;
protected $fillable = [
'cat_id',
'user_id',
'type',
'treatment_name',
'dosage',
'unit',
'date_given',
'next_schedule',
'notes',
];
protected $casts = [
'date_given' => 'date',
'next_schedule' => 'date',
];
public function cat(): BelongsTo
{
return $this->belongsTo(Cat::class);
}
// 2. PASTIKAN RELASI INI BENAR
public function performer(): BelongsTo
{
// Karena kolomnya sekarang user_id (bukan performed_by),
// kita beri tahu Laravel secara eksplisit:
return $this->belongsTo(User::class, 'user_id');
}
}