bugs checked, exclusin age, masih ada bugs value
This commit is contained in:
@@ -27,21 +27,21 @@ class CorporateServiceConfigResource extends JsonResource
|
||||
'exclusions' => $this->specialities->map(function ($speciality) {
|
||||
return [
|
||||
'speciality_id' => $speciality->speciality_id,
|
||||
'rules' => $speciality->exclusions->first()->rules->map(
|
||||
function ($rule) {
|
||||
return [
|
||||
'name' => $rule->name,
|
||||
'value' => explode(',', $rule->values)
|
||||
];
|
||||
}
|
||||
),
|
||||
// 'rules' => $speciality->exclusions->first()->rules->map(
|
||||
// function ($rule) {
|
||||
// return [
|
||||
// 'name' => $rule->name,
|
||||
// 'value' => explode(',', $rule->values)
|
||||
// ];
|
||||
// }
|
||||
// ),
|
||||
|
||||
];
|
||||
}),
|
||||
];
|
||||
|
||||
$list_msc = $this->specialities->map(function ($speciality) {
|
||||
return explode(',', $speciality->exclusions->first()->rules->where('name', 'msc')->first()->values);
|
||||
return explode(',', $speciality->exclusions->first()->rules->where('name', 'msc')->first()->values ?? '');
|
||||
})->map(function ($item) {
|
||||
return [
|
||||
'm' => in_array('m', $item),
|
||||
@@ -49,16 +49,26 @@ class CorporateServiceConfigResource extends JsonResource
|
||||
'c' => in_array('c', $item),
|
||||
];
|
||||
});
|
||||
// $msc = $cek->map(function ($item) {
|
||||
// return [
|
||||
// 'name' => $item,
|
||||
// 'value' => true
|
||||
// ];
|
||||
// });
|
||||
|
||||
$data['exclusions'] = $data['exclusions']->map(function ($item, $key) use ($list_msc) {
|
||||
$list_gender = $this->specialities->map(function ($speciality) {
|
||||
// dd($speciality->exclusions->first()->rules);
|
||||
return explode(',', $speciality->exclusions->first()->rules->where('name', 'gender')->first()->values ?? '');
|
||||
})->map(function ($item) {
|
||||
|
||||
return [
|
||||
'male' => in_array('male', $item),
|
||||
'female' => in_array('female', $item),
|
||||
];
|
||||
});
|
||||
|
||||
$min_age = $this->specialities->map(function ($speciality) {
|
||||
return $speciality->exclusions->first()->rules->where('name', 'min_age')->first()->values ?? '';
|
||||
});
|
||||
|
||||
$data['exclusions'] = $data['exclusions']->map(function ($item, $key) use ($list_msc, $list_gender, $min_age) {
|
||||
$item['msc'] = $list_msc[$key];
|
||||
$item['gender'] = $list_gender[$key];
|
||||
$item['min_age'] = $min_age[$key];
|
||||
return $item;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user