unioil-loyalty-app/app/Http/Resources/LoyaltyCardSignUpResource.php

65 lines
2.3 KiB
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Libraries\S3;
class LoyaltyCardSignUpResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
$this->withoutWrapping();
$details = [
'lcard_s_uuid' => $this->lcard_s_uuid,
'card_type_code' => $this->codeCardType->code,
'firstname' => $this->firstname,
'lastname' => $this->lastname,
'birthdate' => $this->birthdate->toDateString(),
'mobile' => $this->mobile,
'email' => $this->email,
// 'id_number' => $this->id_number,
// 'idnt_name' => isset($this->idNumberType) ? $this->idNumberType->name : "",
// 'photo_id' => $this->photo_id != '' ? S3::public_path($this->photo_id) : null,
// 'photo_document' => $this->photo_document != '' ? S3::public_path($this->photo_document) : null,
// 'selfie' => $this->selfie != '' ? S3::public_path($this->selfie) : null,
// 'selfie_w_card' => $this->selfie_w_card != '' ? S3::public_path($this->selfie_w_card) : null,
];
if($this->id_number != '')
{
$details['id_number'] = $this->id_number;
$details['idnt_name'] = isset($this->idNumberType) ? $this->idNumberType->name : "";
}
if($this->photo_id != '')
{
$details['photo_id'] = $this->photo_id != '' ? S3::public_path($this->photo_id) : null;
}
if($this->photo_document != '')
{
$details['photo_document'] = $this->photo_document != '' ? S3::public_path($this->photo_document) : null;
}
if($this->selfie != '')
{
$details['selfie'] = $this->selfie != '' ? S3::public_path($this->selfie) : null;
}
if($this->selfie_w_card != '')
{
$details['selfie_w_card'] = $this->selfie_w_card != '' ? S3::public_path($this->selfie_w_card) : null;
}
return $details;
}
}