78 lines
3.1 KiB
PHP
78 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use App\Libraries\StaticContents;
|
|
use App\Libraries\S3;
|
|
|
|
class MobileUserProfileResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
$this->withoutWrapping();
|
|
|
|
// $city_uuid = '';
|
|
// $city_name = '';
|
|
// if($this->codeCity)
|
|
// {
|
|
// $city_uuid = $this->codeCity->city_uuid;
|
|
// $city_name = $this->codeCity->name;
|
|
// }
|
|
|
|
$photo_url = '';
|
|
if($this->personalDetails && $this->personalDetails->photo != '')
|
|
{
|
|
// $photo_url = str_replace('/public/index.php','',secure_url('storage/app/'.$this->personalDetails->photo));
|
|
// $photo_url = str_replace('https','http',$photo_url);
|
|
$photo_url = S3::public_path($this->personalDetails->photo);
|
|
}
|
|
|
|
$bg_image = '';
|
|
if($this->codeCardType && $this->codeCardType->bg_image != '')
|
|
{
|
|
$bg_image = S3::public_path($this->codeCardType->bg_image);
|
|
}
|
|
|
|
$card_image = '';
|
|
if($this->codeCardType && $this->codeCardType->image != '')
|
|
{
|
|
$card_image = S3::public_path($this->codeCardType->image);
|
|
}
|
|
|
|
return [
|
|
'lcard_uuid' => $this->lcard_uuid,
|
|
'card_number' => $this->card_number,
|
|
'pin' => $this->pin,
|
|
'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' => $photo_url,
|
|
'address' => $this->personalDetails ? $this->personalDetails->address : '',
|
|
'card_type' => $this->codeCardType ? $this->codeCardType->name : '',
|
|
'card_code' => $this->codeCardType ? $this->codeCardType->code : '',
|
|
'card_image' => $card_image,
|
|
'card_bg_image' => $bg_image,
|
|
'card_black_label' => $this->codeCardType ? $this->codeCardType->is_black : 1,
|
|
'vo_code' => $this->codeVehicleOwn ? $this->codeVehicleOwn->code : '',
|
|
'civilstatus_code' => $this->codeCivilStatus ? $this->codeCivilStatus->code : '',
|
|
'gender_code' => $this->codeGender ? $this->codeGender->code : '',
|
|
'fueltype_code' => $this->codeFuelType ? $this->codeFuelType->code : '',
|
|
// 'city_uuid' => $city_uuid,
|
|
// 'city_name' => $city_name,
|
|
'city_name' => $this->city_name,
|
|
'expiry_date' => $this->expiry_date->toDateString(),
|
|
'points' => $this->total_pts_bal,
|
|
];
|
|
}
|
|
}
|