add fitur delete file dan update daily monitoring
This commit is contained in:
@@ -34,7 +34,7 @@ class RequestDailyMonitoring extends Model
|
||||
'deleted_at'
|
||||
];
|
||||
|
||||
protected $appends = ['medical_plan', 'non_medikamentosa_plan', 'document', 'discharge_date'];
|
||||
protected $appends = ['medical_plan', 'non_medikamentosa_plan', 'document', 'discharge_date', 'confirmation_medical_leter', 'medical_action_letter', 'laboratorium_result'];
|
||||
|
||||
// public function getBodyTemperatureAttribute()
|
||||
// {
|
||||
@@ -99,10 +99,15 @@ class RequestDailyMonitoring extends Model
|
||||
public function getDocumentAttribute()
|
||||
{
|
||||
$arr_document = [];
|
||||
$document = DB::table('files')->where(['fileable_type' => 'App\Models\LaboratoriumResult', 'fileable_id' => $this->attributes['id']])->get();
|
||||
$document = DB::table('files')->where([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'fileable_id' => $this->attributes['id'],
|
||||
'deleted_at' => null,
|
||||
])->get();
|
||||
|
||||
foreach ($document as $row) {
|
||||
$arr_document[] = [
|
||||
'id' => $row->id,
|
||||
'file_name' => $row->original_name,
|
||||
'path' => env('APP_URL') . '/storage/lab_result/' . $row->name .'.'. $row->extension,
|
||||
'type' => $row->type,
|
||||
@@ -117,4 +122,62 @@ class RequestDailyMonitoring extends Model
|
||||
return $discharge_date = DB::table('request_logs')->where('id', $this->attributes['request_log_id'])->select('discharge_date')->first();
|
||||
}
|
||||
|
||||
public function getConfirmationMedicalLeterAttribute()
|
||||
{
|
||||
$arr_document = [];
|
||||
$document = DB::table('files')->where([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'type' => 'confirmation-medical-letter',
|
||||
'fileable_id' => $this->attributes['id'],
|
||||
])->get();
|
||||
|
||||
foreach ($document as $row) {
|
||||
$arr_document[] = [
|
||||
'name' => $row->original_name,
|
||||
'path' => env('APP_URL') . '/storage/lab_result/' . $row->name .'.'. $row->extension,
|
||||
'type' => $row->type,
|
||||
];
|
||||
}
|
||||
|
||||
return $arr_document;
|
||||
}
|
||||
public function getMedicalActionLetterAttribute()
|
||||
{
|
||||
$arr_document = [];
|
||||
$document = DB::table('files')->where([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'type' => 'medical-action-letter',
|
||||
'fileable_id' => $this->attributes['id'],
|
||||
])->get();
|
||||
|
||||
foreach ($document as $row) {
|
||||
$arr_document[] = [
|
||||
'name' => $row->original_name,
|
||||
'path' => env('APP_URL') . '/storage/lab_result/' . $row->name .'.'. $row->extension,
|
||||
'type' => $row->type,
|
||||
];
|
||||
}
|
||||
|
||||
return $arr_document;
|
||||
}
|
||||
public function getLaboratoriumResultAttribute()
|
||||
{
|
||||
$arr_document = [];
|
||||
$document = DB::table('files')->where([
|
||||
'fileable_type' => 'App\Models\LaboratoriumResult',
|
||||
'type' => 'laboratorium-result',
|
||||
'fileable_id' => $this->attributes['id'],
|
||||
])->get();
|
||||
|
||||
foreach ($document as $row) {
|
||||
$arr_document[] = [
|
||||
'name' => $row->original_name,
|
||||
'path' => env('APP_URL') . '/storage/lab_result/' . $row->name .'.'. $row->extension,
|
||||
'type' => $row->type,
|
||||
];
|
||||
}
|
||||
|
||||
return $arr_document;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user