<?php

/*
 * Copyright (c) 2018 Earworks.
 * Codeigniter Project Template Modification
 * Please contact our email for more information :
 *  contact@earworks.co.id
 */
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Description of Console
 *
 * @author Fajar Dwi Rianto <fajar@earworks.co.id>
 * @since 1.0
 */
class Console extends CI_Controller {

    public function __construct() {
        parent::__construct();
        if (!$this->input->is_cli_request()) {
//            show_error('Execute via command line. example: php index.php migrate');
            show_404();
        }
    }

    public function migrate() {
        $this->load->library('migration', array(
            'migration_enabled' => true,
            'migration_path' => APPPATH . 'migrations' . DIRECTORY_SEPARATOR
        ));
        if (!$this->migration->latest()) {
            show_error($this->migration->error_string());
        }
    }

    public function getkey($length = 16) {
        $this->load->library('encryption');
        echo bin2hex($this->encryption->create_key($length)) . "\n";
        exit;
    }

}
