30 lines
790 B
PHP
30 lines
790 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Aturan extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'aturan';
|
|
protected $fillable = ['kode_penyakit', 'kode_indikator', 'nilai_cf'];
|
|
|
|
// Relasi ke tabel penyakit
|
|
public function penyakit()
|
|
{
|
|
return $this->belongsTo(Penyakit::class, 'kode_penyakit', 'id');
|
|
}
|
|
|
|
// Method untuk mengambil data indikator berdasarkan kode_indikator
|
|
public function getIndikatorAttribute()
|
|
{
|
|
// Pisahkan kode_indikator menjadi array
|
|
$indikatorIds = explode(',', $this->kode_indikator);
|
|
|
|
// Ambil data indikator dari tabel indikator
|
|
return Indikator::whereIn('id', $indikatorIds)->get();
|
|
}
|
|
} |