mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
JSON output improved
This commit is contained in:
@@ -35,12 +35,12 @@ class Nation extends REST_Controller
|
||||
|
||||
$result = $this->NationModel->getAll($notLocked, $orderEnglish);
|
||||
|
||||
if(!is_null($result) && $result->num_rows() > 0)
|
||||
if(is_object($result))
|
||||
{
|
||||
$payload = [
|
||||
'success' => TRUE,
|
||||
'message' => 'Nation found',
|
||||
'data' => $result->result()[0]
|
||||
'data' => $result->result()
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
@@ -60,12 +60,12 @@ class Nation extends REST_Controller
|
||||
{
|
||||
$result = $this->NationModel->getFederalState();
|
||||
|
||||
if(!is_null($result) && $result->num_rows() > 0)
|
||||
if(is_object($result))
|
||||
{
|
||||
$payload = [
|
||||
'success' => TRUE,
|
||||
'message' => 'Bundesland found',
|
||||
'data' => $result->result_array()
|
||||
'data' => $result->result()
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
|
||||
@@ -39,26 +39,14 @@ class Person extends REST_Controller
|
||||
|
||||
$result = $this->PersonModel->getPerson($personID, $code, $email);
|
||||
|
||||
if(!is_null($result) && $result->num_rows() > 0)
|
||||
if(is_object($result))
|
||||
{
|
||||
if($result->num_rows() > 1)
|
||||
{
|
||||
$payload = [
|
||||
'success' => TRUE,
|
||||
'message' => 'People found',
|
||||
'data' => $result->result()[0]
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
else if($result->num_rows() == 1)
|
||||
{
|
||||
$payload = [
|
||||
'success' => TRUE,
|
||||
'message' => 'Person found',
|
||||
'data' => $result->result()[0]
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
$payload = [
|
||||
'success' => TRUE,
|
||||
'message' => 'People found',
|
||||
'data' => $result->result()
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -98,6 +86,32 @@ class Person extends REST_Controller
|
||||
}
|
||||
$this->response($payload, $httpstatus);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function postInterestedStudent()
|
||||
{
|
||||
$result = $this->PersonModel->saveInterestedStudent($this->post());
|
||||
|
||||
if($result === TRUE)
|
||||
{
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
$payload = [
|
||||
'success' => true,
|
||||
'message' => 'Interested student saved.'
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
$payload = [
|
||||
'success' => false,
|
||||
'message' => 'Could not save interested student.'
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
$this->response($payload, $httpstatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
@@ -140,30 +154,4 @@ class Person extends REST_Controller
|
||||
|
||||
$this->response($payload, $httpstatus);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function postInterestedStudent()
|
||||
{
|
||||
$result = $this->PersonModel->saveInterestedStudent($this->post());
|
||||
|
||||
if($result === TRUE)
|
||||
{
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
$payload = [
|
||||
'success' => true,
|
||||
'message' => 'Interested student saved.'
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
$payload = [
|
||||
'success' => false,
|
||||
'message' => 'Could not save interested student.'
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
$this->response($payload, $httpstatus);
|
||||
}
|
||||
}
|
||||
@@ -32,12 +32,12 @@ class Course extends REST_Controller
|
||||
{
|
||||
$result = $this->CourseModel->getEnabledCourses();
|
||||
|
||||
if(!is_null($result) && $result->num_rows() > 0)
|
||||
if(is_object($result))
|
||||
{
|
||||
$payload = [
|
||||
'success' => TRUE,
|
||||
'message' => 'Courses found',
|
||||
'data' => $result->result()[0]
|
||||
'data' => $result->result()
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ class Course extends REST_Controller
|
||||
{
|
||||
$payload = [
|
||||
'success' => FALSE,
|
||||
'message' => 'Person not found'
|
||||
'message' => 'No courses found'
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
|
||||
@@ -34,12 +34,12 @@ class Plan extends REST_Controller
|
||||
|
||||
$result = $this->PlanModel->getCurricula($courseOfStudiesID);
|
||||
|
||||
if(!is_null($result) && $result->num_rows() > 0)
|
||||
if(is_object($result))
|
||||
{
|
||||
$payload = [
|
||||
'success' => TRUE,
|
||||
'message' => 'Curricula found',
|
||||
'data' => $result->result()[0]
|
||||
'data' => $result->result()
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user