bookingRoomPaxRepository = $bookingRoomPaxRepository; } public function create($params = []) { $response = ['status' => -1, 'message' => '', 'data' => null]; try { /*$validationResult = $this->propertyChannelAddValidator->validate($params); if ($validationResult->errors()->first()) { $errors = $validationResult->errors()->all(); throw new ApiErrorException($errors); }*/ $insertData = [ 'booking_id' => fillOnUndefined($params, 'booking_id'), 'booking_room_id' => fillOnUndefined($params, 'booking_room_id'), 'type' => fillOnUndefined($params, 'type'), 'name' => fillOnUndefined($params, 'name'), 'surname' => fillOnUndefined($params, 'surname'), 'gender' => fillOnUndefined($params, 'gender'), 'citizen' => fillOnUndefined($params, 'citizen'), 'birth_date' => fillOnUndefined($params, 'birth_date'), 'status' => fillOnUndefined($params, 'status', 1), ]; $userCreateResult = $this->bookingRoomPaxRepository->create($insertData); if ($userCreateResult['status'] != 'success') { throw new Exception('api-unknown_error'); } $userData = $userCreateResult["data"]; $response = [ 'status' => true, 'data' => $userData, ]; } catch (ApiErrorException $e) { $response['message'] = implode(', ', $e->getMessageArr()); } catch (Exception $e) { $message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage(); Log::error($message); $response['message'] = $e->getMessage(); } return output($response); } public function select($param = [], $column = ['*']) { $response = ['status' => -1, 'message' => '', 'data' => null]; try { $data = $this->bookingRoomPaxRepository->findByCriteria($param, $column); $response = [ 'status' => true, 'data' => $data, ]; } catch (ApiErrorException $e) { $response['message'] = $e->getMessage(); } catch (Exception $e) { $message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage(); Log::error($message); $response['message'] = $e->getMessage(); } return output($response); } public function update($id, $param = []) { $response = ['status' => -1, 'message' => '', 'data' => null]; try { $updateResult = $this->bookingRoomPaxRepository->update($id, $param); if ($updateResult['status'] != 'success') { throw new Exception('api-unknown_error'); } $updateData = $updateResult["data"]; $response = [ 'status' => true, 'data' => $updateData, ]; } catch (ApiErrorException $e) { $response['message'] = implode(', ', $e->getMessageArr()); } catch (Exception $e) { $message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage(); Log::error($message); $response['message'] = $e->getMessage(); } return output($response); } }