55 lines
2.7 KiB
PHP
55 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use App\Libraries\StaticContents;
|
|
use App\AdminActionLogs;
|
|
use App\Helpers\CurrentUserHelper;
|
|
|
|
class LoyaltyCardResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
$this->withoutWrapping();
|
|
|
|
$activated = AdminActionLogs::where('id',$this->lcard_id)
|
|
->where('module','Member Management')
|
|
->where('action','activate')
|
|
->first();
|
|
|
|
return [
|
|
'lcard_uuid' => $this->lcard_uuid,
|
|
'card_number' => $this->card_number,
|
|
'pin' => $this->pin,
|
|
'expiry_date' => $this->expiry_date != null ? date('F d, Y',strtotime($this->expiry_date)) : null,
|
|
'birthdate' => date('F d, Y',strtotime($this->birthdate)),
|
|
'mobile' => $this->mobile,
|
|
'email' => $this->email,
|
|
'firstname' => $this->personalDetails ? $this->personalDetails->firstname : '',
|
|
'middlename' => $this->personalDetails ? $this->personalDetails->middlename : '',
|
|
'lastname' => $this->personalDetails ? $this->personalDetails->lastname : '',
|
|
'photo' => $this->personalDetails ? $this->personalDetails->photo : '',
|
|
'address' => $this->personalDetails ? $this->personalDetails->address : '',
|
|
'card_type' => $this->codeCardType ? $this->codeCardType->name : '',
|
|
'vehicle_own' => $this->codeVehicleOwn ? $this->codeVehicleOwn->description : '',
|
|
'civil_status' => $this->codeCivilStatus ? $this->codeCivilStatus->description : '',
|
|
'gender' => $this->codeGender ? $this->codeGender->description : '',
|
|
'status' => $this->is_locked == 1 ? 'locked' : StaticContents::member_status($this->is_validated),
|
|
'validation_dt' => $this->validation_dt != null ? date('Y-m-d H:i:s',strtotime($this->validation_dt)) : null,
|
|
'is_locked' => $this->is_locked,
|
|
'lock_dt' => $this->lock_dt != null ? $this->lock_dt : null,
|
|
'reason' => $this->lock_code != '' ? StaticContents::lock_code($this->lock_code): null,
|
|
'created_at' => $this->created_at != null ? $this->created_at->toDateTimeString() : null,
|
|
'updated_at' => $this->updated_at != null ? $this->updated_at->toDateTimeString() : null,
|
|
'unlocked_by' => $activated ? CurrentUserHelper::getAdminName($activated->created_by) : null,
|
|
];
|
|
}
|
|
}
|