methods['addSubjectDetails_get']['limit'] = 500; // 500 requests per hour per user/key $this->methods['addSubjectDetails_post']['limit'] = 100; // 100 requests per hour per user/key $this->methods['addSubjectDetails_delete']['limit'] = 50; // 50 requests per hour per user/key $this->methods['getSubjectDetails_post']['limit'] = 500; // 50 requests per hour per user/key $this->methods['updateSubjectDetails_post']['limit'] = 500;// 500 requests per hour per user/key // load the model $this->load->model('Subject_model', 'subject_model'); } /* * This method used to add Subject details * * */ public function addSubjectDetails_post() { $now = new DateTime(); $now->setTimezone(new DateTimezone('Asia/Kolkata')); $details['SubjectCode'] = $this->post('SubjectCode'); $details['SubjectName'] = $this->post('SubjectName'); $details['IsActive'] = $this->post('Status'); $details['CreatedBy'] = $this->post('createdBy'); $details['CreatedOn'] = $now->format('Y-m-d H:i:s'); $subjectDetails = $this->subject_model->addSubject($details);// Check if the users data store contains users (in case the database result returns NULL) if ($subjectDetails) { $subjectDetails['status'] = REST_Controller::HTTP_OK; // Set the response and exit $this->response($subjectDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code } else { // Set the response and exit $this->response([ 'message' => 'Something went wrong.please try again!', 'status' => REST_Controller::HTTP_NOT_FOUND ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code } } /* * get Subject details * * */ public function getSubjectDetails_post() { $requestedBy = $this->post('requestedBy'); $getSubject = $this->subject_model->getSubject($requestedBy); if ($getSubject) { $getSubject['status'] = REST_Controller::HTTP_OK; // Set the response and exit $this->response($getSubject, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code } else { // Set the response and exit $this->response([ 'message' => 'No records found!', 'status' => REST_Controller::HTTP_NOT_FOUND ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code } } /* * update Subject details * * */ public function updateSubjectDetails_post() { $now = new DateTime(); $now->setTimezone(new DateTimezone('Asia/Kolkata')); $details['SubjectCode'] = $this->post('SubjectCode'); $details['SubjectName'] = $this->post('SubjectName'); $SubjectID = $this->post('SubjectID'); $details['IsActive'] = $this->post('Status'); $details['UpdatedBy'] = $this->post('updatedBy'); $details['UpdatedOn'] = $now->format('Y-m-d H:i:s'); // print_r($SubjectID);die(); $updateDetails = $this->subject_model->updateSubject($details,$SubjectID);// Check if the users data store contains users (in case the database result returns NULL) // print_r($details,$SubjectID);die(); if ($updateDetails) { $updateDetails['status'] = REST_Controller::HTTP_OK; // Set the response and exit $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code } else { // Set the response and exit $this->response([ 'message' => 'Something went wrong.please try again!', 'status' => REST_Controller::HTTP_NOT_FOUND ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code } } }