I have created a function in my model PatientDetail.php.
This function is working well and returning the desired value, but I am not able to save the same in database.
public function getRoomCategory(){
$model = \app\models\RoomCategory::find('id')
->innerJoin('room_charges','room_charges.room_category=room_category.id')
->innerjoin('patient_detail', 'room_charges.id = patient_detail.bed_type')
->Where(['patient_detail.id'=> $this->id])->one();
return $model;
}
I have a field/Column in the model as ‘room_category’ and I want to save the return value of the function getRoomCategory in the Database.
I have tried to create the function with the same name like getroom_category(){}, but then I am not getting any value in the form field in my _form.php
What is the best way to save the calculated value to the database? Thank for your valuable guidance.