initial commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user