Update Digital Card Get Member Detail

This commit is contained in:
R
2023-02-20 15:03:05 +07:00
parent 5c71b556a0
commit dba421ad0b
3 changed files with 22 additions and 6 deletions

View File

@@ -251,4 +251,12 @@ class MembershipController extends Controller
return Helper::responseJson(data: [], message: 'Member Tidak ditemukan', statusCode: 404, status: 'error');
}
public function show($member_id)
{
$member = Member::where('member_id', $member_id)->firstOrFail();
$member->load(['currentPlan', 'memberPlans']);
return Helper::responseJson(data: MemberResource::make($member));
}
}

View File

@@ -16,11 +16,6 @@ class MemberResource extends JsonResource
{
// $data = parent::toArray($request);
$currentMemberPlan = $this->memberPlans?->first();
$currentPlan = $currentMemberPlan ? [
'code' => $currentMemberPlan->plan->code ?? null,
'start' => $currentMemberPlan->start,
'end' => $currentMemberPlan->end
] : null;
$data = [
'member_id' => $this->member_id,
@@ -29,7 +24,19 @@ class MemberResource extends JsonResource
'phone' => $this->person->phone ?? null,
'full_name' => $this->full_name,
'nric' => $this->nric,
'plan' => $currentPlan
'plan' => $currentMemberPlan ? [
'code' => $currentMemberPlan->plan->code ?? null,
'start' => $currentMemberPlan->start,
'end' => $currentMemberPlan->end
] : null,
'policy_code' => $this->currentPolicy->code,
'corporate' => [
'code' => $this->currentPolicy->corporate->code,
'name' => $this->currentPolicy->corporate->name,
'welcome_message' => $this->currentPolicy->corporate->welcome_message,
'help_text' => $this->currentPolicy->corporate->help_text,
'avatar_url' => $this->currentpolicy->corporate->avatar_url
]
];
return $data;
}

View File

@@ -19,6 +19,7 @@ use Illuminate\Support\Facades\Route;
*/
Route::middleware('linksehat.old.auth')->group(function() {
Route::get('member/{member_id}', [MembershipController::class, 'show'])->name('member.show');
Route::post('check-membership', [MembershipController::class, 'check']);
Route::post('check-limit', [MembershipController::class, 'checkLimit']);
Route::post('check-coverage-limit', [MembershipController::class, 'checkLimit']);