/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $dataAccess = new ClientMng();
     $dataAccess1 = new DataAccess();
     $id = $dataAccess1->currentUserID();
     $patient = $dataAccess->getPatient($id);
     $list = ['userid' => $id, 'firstName' => $patient["firstName"], 'lastName' => $patient["lastName"], 'dob' => "{$request->year}-{$request->month}-{$request->day}", 'email' => $patient["email"], 'gender' => $request->sex, 'height' => $request->height, 'weight' => $request->weight, 'mobileNum' => $request->phone, 'homeNum' => $request->home_phone, 'address' => $request->address, 'city' => $request->city, 'postalCode' => $request->postal_code, 'state' => $request->state, 'country' => $request->country, 'occupation' => $request->occupation, 'maritalStatus' => $request->status, 'nextOfKin' => $request->next_kin];
     $dataAccess->clientInfoSave($list, Auth::user()->email);
     $json = json_encode(array("data" => $list));
     //
     //        $server = ['Content-Type'=>"application/json"];
     //        //"$uri, $method = 'GET', $parameters = array(), $cookies = array(), $files = array(), $server = array(), $content = null"
     //
     $postRequest = Request::create('/api/clients', 'POST', [], [], [], [], $json);
     $headers = $postRequest->headers;
     $headers->set('Content-Type', 'application/json');
     $headers->set('Accept', 'application/json');
     //echo print_r($headers);
     $response = Route::dispatch($postRequest);
     //        $postRequest->headers = array('CONTENT_TYPE'=> 'application/json');
     //        $postRequest->attributes = $json;
     //        $response = Route::dispatch($postRequest);
     //echo print_r($postRequest);
     //echo $postRequest;
     ////
     //        $headers = array();
     //        $headers[] = 'Content-Type: application/json';
     //        $username = "******";
     //        $password = "******";
     //
     //        // create a new cURL resource
     //        $ch = curl_init();
     //
     //        // set URL and other appropriate options
     //        curl_setopt($ch, CURLOPT_URL, "http://localhost:8000/api/clients");
     //        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     //        curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
     //        curl_setopt($ch, CURLOPT_POST, 1);
     //        curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
     //        curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
     //        curl_setopt ($ch, CURLOPT_PORT , 8089);
     //
     //        // grab URL and pass it to the browser
     //        $response = curl_exec($ch);
     //        echo print_r($response);
     //        $info = curl_getinfo($ch);
     //        echo print_r($info["http_code"]);
     //
     ////        if ($response === false)
     ////        {
     ////            // throw new Exception('Curl error: ' . curl_error($crl));
     ////            print_r('Curl error: ' . curl_error($response));
     ////        }
     //        //echo $response;
     //
     //        // close cURL resource, and free up system resources
     //        curl_close($ch);
     return redirect('home');
 }