<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Season
 *
 * @author user
 */
require APPPATH . '/libraries/REST_Controller.php';
class Season extends REST_Controller{
    
    function __construct() {
        parent::__construct();
        $this->load->database();
        $this->load->model('Season_modal');
        $this->load->model('Token_modal');
    }
    
    public function season_get() {
        $headers = $this->input->request_headers();
        $valid = $this->Token_modal->exit_token($headers['Token']);
        if ($valid != null) {
            
            $seasons = $this->Season_modal->get_all_seasons();
            $seasons_list = array("Season" => $seasons);
            $message = array("Status" => "200",
                "SeasonList" => $seasons_list);
            $response_message = array("GetSeasonListResponse" => $message);
            $this->response($response_message);
        } else {
            $message = array("Status" => "1002",
                "Message" => "Invalid token");
            $response_message = array("GetSeasonListResponse" => $message);
            $this->response($response_message);
        }
    }
}
