apollodec/Apollo/api/application/controllers/Student_Controller.php
2017-11-27 18:11:24 +05:30

113 lines
4.5 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
// This can be removed if you use __autoload() in config.php OR use Modular Extensions
/** @noinspection PhpIncludeInspection */
require_once APPPATH . '/libraries/REST_Controller.php';
/**
* This is an example of a few basic user interaction methods you could use
* all done with a hardcoded array
*
* @package CodeIgniter
* @subpackage Rest Server
* @category Controller
* @author
* @license MIT
* @link
*/
class Student_Controller extends REST_Controller {
/*
* get student details
* params:
* created by kdk
* */
function __construct()
{
// Construct the parent class
parent::__construct();
// Configure limits on our controller methods
// Ensure you have created the 'limits' table and enabled 'limits' within application/config/rest.php
$this->methods['addStudent_post']['limit'] = 100;
// load the employee model
$this->load->model('Student_model', 'student_model');
}
public function getCourseBatch_post() {
$data = $this->post('data');
$getCourseBatchListDetails = $this->student_model->get_courseBatch_list($data);// Check if the employee exist
if ($getCourseBatchListDetails)
{
$getCourseBatchListDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getCourseBatchListDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
}
else
{
// Set the response and exit
$this->response([
'message' => 'No list were found',
'status' => REST_Controller::HTTP_NOT_FOUND
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
}
}
// add student
public function addStudent_post() {
$data = $this->post('data');
$createdBy = $this->post('createdBy');
$createdBranch = $this->post('loginBranch');
$req['Firstname'] = $data['firstname'];
$req['Lastname'] = $data['lastname'];
$req['Fathername'] = $data['fathername'];
$req['EmailID'] = $data['emailId'];
$req['MotherName'] = $data['mothername'];
$req['MobileNumber'] = $data['primaryPhone'];
$req['AlternateNumber'] = $data['secondaryPhone'];
$req['Gender'] = $data['gender'];
$req['DOB'] = $data['dateofbirth'];
$req['PresentAddress'] = $data['address2'];
$req['PermanentAddress'] = $data['address1'];
$req['AadharNumber'] = $data['aadharNumber'];
$req['OtherID'] = $data['otherId'];
$req['OtherIDDetails'] = $data['otherIdDetails'];
$req['Caste'] = $data['caste'];
$req['Category'] = $data['category'];
$req['Religion'] = $data['religion'];
$req['Nationality'] = $data['nationality'];
$req['Occupation'] = $data['occupation'];
$req['Designation'] = $data['designation'];
$req['Companyname'] = $data['companyname'];
$req['ReferredBy'] = $data['referredby'];
$req['ReferersMobileNumber'] = $data['referredmobilenumber'];
$req['PreQualification'] = $data['prequalification'];
$req['IsActive'] = $data['switchsetting'];
$req['CreatedBy'] = $createdBy;
$date = date('Y-m-d H:i:s');
$req['CreatedOn'] = $date;
print_r($req);exit();
$studentAdd = $this->student_model->add_student( $req );// Check if the employee exist
if ($studentAdd)
{
$studentAdd['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($studentAdd, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
}
else
{
// Set the response and exit
$this->response([
'message' => 'No users were found',
'status' => REST_Controller::HTTP_NOT_FOUND
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
}
}
}