<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class RekamMedis extends Model
{
use HasFactory, SoftDeletes;
protected $guarded = [];
public function pasien(){
return $this->belongsTo(Pasien::class)->withTrashed();
}
public function dokterRm(){
return $this->hasMany(DokterRekamMedis::class);
}
public function obatRm(){
return $this->hasMany(ObatRekamMedis::class);
}
public function getDokterIdAttribute()
{
$dokter_id = [];
foreach ($this->dokterRm as $dokter) {
if ($dokter->jenis_terapis == "Utama") {
$dokter_id[] = $dokter->dokter_id;
}
}
return $dokter_id;
}
public function getObatIdAttribute()
{
$obat_id = [];
foreach ($this->obatRm as $obat) {
$obat_id[] = $obat->obat_id;
}
return $obat_id;
}
public function getTotalDenganDiskonAttribute()
{
return $this->total - ($this->total * $this->diskon/100);
}
}
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]