request = $request ; $this->propertyAwardsCertificateService = $propertyAwardsCertificateService ; } public function getAwardCertificateCategories( ){ $response = ['status' => false, 'message' => '', 'data' => null, 'statusCode' => 500]; try { if (is_null($this->request->getContent())) { throw new ApiErrorException(lang('Parameter Error.')); } $params = $this->request->params; $getPropertyAwardsCertificateList = $this->propertyAwardsCertificateService->getCategoryList($params); if($getPropertyAwardsCertificateList['status'] != 'success'){ throw new Exception($getPropertyAwardsCertificateList['message']); } $responseData['award_certificate_categories'] = $getPropertyAwardsCertificateList['data'] ; $response = ['status' => 1, 'statusCode' => 200, 'message' => null, 'data' => $responseData]; } catch (ApiErrorException $e) { $response['message'] = implode(', ', $e->getMessageArr()); $response['statusCode'] = 400; } catch (Exception $e) { $message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage(); Log::error($message); $response['message'] = $e->getMessage(); $response['statusCode'] = 500; } return apiResponse($response['status'], $response['message'], $response['data'], $response['statusCode']); } public function createAwardsCertificates(Request $request) { $response = ['status' => false, 'message' => '', 'data' => null, 'statusCode' => 500]; try { $params = [ "property_id" => $request->input('property_id'), "category_id" => $request->input('category_id'), "language_code" => $request->input('language_code'), "name" => $request->input('name'), "date" => $request->input('date'), "url" => $request->input('url'), "file" => $request->file('file'), ]; $requestParams = $params; $requestParams['user_id'] = $this->request->auth->id; $storeAwardsCertificate = $this->propertyAwardsCertificateService->create($requestParams); if ($storeAwardsCertificate['status'] != 'success') { throw new ApiErrorException($storeAwardsCertificate['message']); } $response = ['status' => 1, 'statusCode' => 200, 'message' => null, 'data' => $storeAwardsCertificate['data']]; } catch (ApiErrorException $e) { $response['message'] = implode(', ', $e->getMessageArr()); $response['statusCode'] = 400; } catch (Exception $e) { $message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage(); Log::error($message); $response['message'] = $e->getMessage(); $response['statusCode'] = 500; } return apiResponse($response['status'], $response['message'], $response['data'], $response['statusCode']); } public function listAwardsCertificates(Request $request) { $response = ['status' => false, 'message' => '', 'data' => null, 'statusCode' => 500]; try { if (is_null($this->request->getContent())) { throw new ApiErrorException(lang('Parameter Error.')); } $params = $this->request->params; $params['user_id'] = $this->request->auth->id; $storeAwardsCertificate = $this->propertyAwardsCertificateService->listAwardsCertificates($params); if ($storeAwardsCertificate['status'] != 'success') { throw new ApiErrorException($storeAwardsCertificate['message']); } $response = ['status' => 1, 'statusCode' => 200, 'message' => null, 'data' => $storeAwardsCertificate['data']]; } catch (ApiErrorException $e) { $response['message'] = implode(', ', $e->getMessageArr()); $response['statusCode'] = 400; } catch (Exception $e) { $message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage(); Log::error($message); $response['message'] = $e->getMessage(); $response['statusCode'] = 500; } return apiResponse($response['status'], $response['message'], $response['data'], $response['statusCode']); } public function updateAwardsCertificates(Request $request) { $response = ['status' => false, 'message' => '', 'data' => null, 'statusCode' => 500]; try { $params = [ "award_certificate_id" => $request->input('award_certificate_id'), "property_id" => $request->input('property_id'), "category_id" => $request->input('category_id'), "language_code" => $request->input('language_code'), "name" => $request->input('name'), "date" => $request->input('date'), "url" => $request->input('url'), "file" => $request->file('file'), ]; $requestParams = $params; $requestParams['user_id'] = $this->request->auth->id; $storeAwardsCertificate = $this->propertyAwardsCertificateService->update($requestParams); if ($storeAwardsCertificate['status'] != 'success') { throw new ApiErrorException($storeAwardsCertificate['message']); } $response = ['status' => 1, 'statusCode' => 200, 'message' => null, 'data' => $storeAwardsCertificate['data']]; } catch (ApiErrorException $e) { $response['message'] = implode(', ', $e->getMessageArr()); $response['statusCode'] = 400; } catch (Exception $e) { $message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage(); Log::error($message); $response['message'] = $e->getMessage(); $response['statusCode'] = 500; } return apiResponse($response['status'], $response['message'], $response['data'], $response['statusCode']); } public function deletePhotoAwardsCertificates(Request $request) { $response = ['status' => false, 'message' => '', 'data' => null, 'statusCode' => 500]; try { if (is_null($this->request->getContent())) { throw new ApiErrorException(lang('Parameter Error.')); } $params = $this->request->params; $params['user_id'] = $this->request->auth->id; $storeAwardsCertificate = $this->propertyAwardsCertificateService->deletePhotoAwardsCertificates($params); if ($storeAwardsCertificate['status'] != 'success') { throw new ApiErrorException($storeAwardsCertificate['message']); } $response = ['status' => 1, 'statusCode' => 200, 'message' => null, 'data' => $storeAwardsCertificate['data']]; } catch (ApiErrorException $e) { $response['message'] = implode(', ', $e->getMessageArr()); $response['statusCode'] = 400; } catch (Exception $e) { $message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage(); Log::error($message); $response['message'] = $e->getMessage(); $response['statusCode'] = 500; } return apiResponse($response['status'], $response['message'], $response['data'], $response['statusCode']); } public function updateStatusAwardsCertificates(Request $request) { $response = ['status' => false, 'message' => '', 'data' => null, 'statusCode' => 500]; try { if (is_null($this->request->getContent())) { throw new ApiErrorException(lang('Parameter Error.')); } $params = $this->request->params; $params['user_id'] = $this->request->auth->id; $storeAwardsCertificate = $this->propertyAwardsCertificateService->updateStatus($params); if ($storeAwardsCertificate['status'] != 'success') { throw new ApiErrorException($storeAwardsCertificate['message']); } $response = ['status' => 1, 'statusCode' => 200, 'message' => null, 'data' => $storeAwardsCertificate['data']]; } catch (ApiErrorException $e) { $response['message'] = implode(', ', $e->getMessageArr()); $response['statusCode'] = 400; } catch (Exception $e) { $message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage(); Log::error($message); $response['message'] = $e->getMessage(); $response['statusCode'] = 500; } return apiResponse($response['status'], $response['message'], $response['data'], $response['statusCode']); } }