/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store() { $user = new User(); $deviceDetail = new DeviceDetails(); $data = Input::all(); $validator = $this->checkValidation(); if ($validator->fails()) { $messages = $validator->messages(); foreach ($messages->all() as $message) { $msg[] = $message; } return $this->errorMessage($msg); } $userId = $user->getUserIdAttachedWithTpId($data['tp_id'], $data['id_type']); if ($userId) { $data['user_id'] = $userId; } $img_hash = $user->imageUpload($data['img_hash'], $this->uploaddir); if (isset($img_hash) and !empty($img_hash)) { $data['img_hash'] = $img_hash; } $userProfile = $user->insert($data); $userProfile->lat = $data['lat']; $userProfile->lng = $data['lng']; $data['user_id'] = $userProfile->id; $deviceDetail->insert($data); $msg[] = "Profile saved successfully."; return $this->successMessageWithVar($msg, $userProfile); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $data = Input::all(); $user = new User(); $deviceDetail = new DeviceDetails(); $validator = $this->checkValidationForProfileUpdate(); if ($validator->fails()) { $messages = $validator->messages(); foreach ($messages->all() as $message) { $msg[] = $message; } return $this->errorMessage($msg); } if (isset($data['img_hash']) and !empty($data['img_hash'])) { $imageBase64Data = $data['img_hash']; $img_hash = $user->imageUpload($imageBase64Data, $this->uploaddir); if (isset($img_hash) and !empty($img_hash)) { $data['img_hash'] = $img_hash; } } $data['user_id'] = $id; $userProfile = $user->insert($data); $deviceDetail->insert($data); $msg = "Profile updated successfully."; return $this->successMessageWithVar($msg, $userProfile); }