format = $httpStatusCode; $this->lcard_logs = $lcard_logs; $this->module = "SharedTreats"; $this->model = "SharedTreats"; $this->url_encryption = Config::get('app.sharedtreatsEncryption'); $this->url_gateway = Config::get('app.sharedtreatsGateway'); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $return = []; $member_details = CurrentUserHelper::get_currentMember(); if (empty($member_details->card_number)){ return $this->format->mobile_error('Something went wrong'); } if (empty($member_details->mobile)){ return $this->format->mobile_error('Something went wrong'); } if(!$this->checkMobileNumber($member_details->mobile)){ return $this->format->mobile_error('Something went wrong'); } $card = $member_details->card_number."/1"; $data = $this->create_request($card); $encrypted_uuid = $data->result_value; $data = $this->create_request($member_details->mobile); $encrypted_mobile = $data->result_value; $return['site'] = $this->url_gateway.$encrypted_uuid."/".$encrypted_mobile; $this->lcard_logs->log("0",'SHAREDTREATS','VIEW'); return $this->format->mobile_success('Shared Treats',$return); } public function checkMobileNumber($mobileNumber) { if (mb_substr($mobileNumber, 0, 2) == "63"){ return $mobileNumber; }elseif(mb_substr($mobileNumber, 0, 2) == "09" ){ return "63".substr($mobileNumber, -10); }elseif(mb_substr($mobileNumber, 0, 1) == "9"){ return "63".substr($mobileNumber, -10); }else{ return false; } } public function create_request($params) { $url = $this->url_encryption ; $this->uri = new Uri($url.$params); $client = new Client(); $response = $client->request('GET', $this->uri,[]); return json_decode($response->getBody()->getContents()) ; } }