Esempio n. 1
0
 /**
  * Delete a job by given id.
  * Note: This will also delete all candidates applied for the job.
  *
  * @api DELETE /jobs/:id - Delete job.
  * @apiParam Integer id - Job id..
  * @apiExample Example CURL usage
  *      curl -i --request DELETE http://localhost/jobs/1
  *
  * @param $args Array
  */
 public function delete($args)
 {
     // return bad request response if there is not an ID passed.
     if (!isset($args['id'])) {
         return Response::badRequest(['message' => 'Missing job id.']);
     }
     $output = $this->jobs->delete($args);
     // return bad request response if there are validation errors
     if (isset($output['error']) && $output['error'] === 'validation') {
         return Response::badRequest($output['data']);
     }
     // return no content response if there are no records for a job
     if ($output === 0) {
         return Response::noContent();
     }
     return Response::success(['message' => 'Successfully deleted ' . $output . ' record(s)']);
 }
 /**
  * Search for job's application(s) by given id.
  *
  * @api GET /candidates/search/:id
  * @apiParam Integer id - Job's application id.
  * @apiExample Example CURL usage
  *      curl -i --request GET http://localhost/candidates/search/1
  *
  * @param $args Array
  */
 public function search($args)
 {
     // return bad request response if there is not an ID passed.
     if (!isset($args['id'])) {
         return Response::badRequest(['message' => 'Missing application id.']);
     }
     $output = $this->candidates->search($args['id']);
     // return bad request response if there are some kind of a validation errors
     if (isset($output['error']) && $output['error'] === 'validation') {
         return Response::badRequest($output['data']);
     }
     // return no content response if there are no records for the job application
     if (count($output) < 1) {
         return Response::noContent();
     }
     return Response::success($output);
 }