Advertisement
vdp

Untitled

vdp
Jun 26th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. require APPPATH . '/libraries/REST_Controller.php';
  4. class Family extends REST_Controller
  5. {
  6.     function __construct($config = 'rest') {
  7.       parent::__construct($config);
  8.       $this->load->database();
  9.       $this->load->model('FamilyModel');
  10.     }
  11.     public function api_post(){
  12.       $headers = $this->input->request_headers();
  13.       if (array_key_exists('Authorization', $headers) && !empty($headers['Authorization'])) {
  14.           $decodedToken = AUTHORIZATION::validateToken($headers['Authorization']);
  15.           if ($decodedToken != false) {
  16.             $id_user = $this->post('id_user');
  17.             $id_user_family = $this->post('id_user_family');
  18.             $response = $this->FamilyModel->addFamily($id_user,$id_user_family);
  19.             $this->set_response($response, REST_Controller::HTTP_OK);
  20.           }
  21.       }else{
  22.         $this->set_response("Unauthorised", REST_Controller::HTTP_UNAUTHORIZED);
  23.       }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement