Merge remote-tracking branch 'origin/staging' into origin/production

This commit is contained in:
Server D3 Linksehat
2024-10-16 14:14:14 +07:00
3 changed files with 129 additions and 3 deletions

View File

@@ -210,7 +210,31 @@ class CorporateMemberController extends Controller
};
$query->getQuery()->orderBy($orderBy, $request->order);
})
->paginate($per_page);
->when($request->search, function ($q, $search) {
$q->where('code', 'LIKE', "%".$search."%");
$q->orWhereHas('member', function ($subQuery) use ($search) {
$subQuery->where('name', 'LIKE', "%".$search."%");
});
})
->when($request->status, function ($q, $search) {
if ($search == 'kondisi') {
$q->whereHas('files', function ($subQuery) {
$subQuery->where('type', 'final-log-kondisi');
});
} elseif ($search == 'diagnosa') {
$q->whereHas('files', function ($subQuery) {
$subQuery->where('type', 'final-log-diagnosis');
});
} elseif ($search == 'result') {
$q->whereHas('files', function ($subQuery) {
$subQuery->where('type', 'final-log-result');
});
} elseif ($search == 'none') {
$q->doesntHave('files');
}
})
->with(['member','files'])
->paginate($per_page);
return response()->json(['full_name' => $member->full_name?? null, 'paginations' => Helper::paginateResources(DataListClaimMemberResource::collection($data))]);
}

View File

@@ -6,6 +6,8 @@ use Illuminate\Http\Resources\Json\JsonResource;
use App\Models\Service;
use App\Models\Organization;
use Illuminate\Support\Str;
class DataListClaimMemberResource extends JsonResource
{
/**
@@ -16,12 +18,15 @@ class DataListClaimMemberResource extends JsonResource
*/
public function toArray($request)
{
$filesGroupByType = $this->files->mapToGroups(function($file) {
return [Str::slug($file->type, '_') => $file];
});
$serviceData = Service::where('code', $this->service_code)->first();
$organization = Organization::where('id', $this->organization_id)->first();
$organizationName = '-';
if ($organization){
$organizationName = $organization->name;
}
}
if ($serviceData) {
$serviceName = $serviceData->name;
} else {
@@ -43,6 +48,7 @@ class DataListClaimMemberResource extends JsonResource
'provider_name' => $organizationName ?? null,
'service_type' => $serviceName,
'status' => $status,
'files_by_type' => $filesGroupByType
];
}
}