<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Video extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('model_app');
        $this->isLoggedIn();
    }

    function isLoggedIn() {
        $isLoggedIn = $this->session->userdata('isLoggedIn');
        if ($isLoggedIn == false) {
            $this->session->set_flashdata('message_red_password', 'LOGIN DULUUUU CUY !');
            redirect('admin/loginpage');
        }
    }

    private $table = 'video';
    private $control = 'admin/video';
    private $folder_view = 'super/video';

    public function index() {
        $query_slider = "SELECT * FROM $this->table";
        $data = array(
            'data_slider' => $this->model_app->manualQuery($query_slider)
        );
        renderSuper("$this->folder_view/data", $data);
    }
    
    function simpanData(){
        $data = array(
            'title' => $_POST['title'],
            'linkvideo' => $_POST['linkvideo'],
        );
        $this->db->insert($this->table, $data);
        redirect($this->control);
    }
    
    function hapus(){
        $key['id'] = $this->uri->segment(4);
        $this->model_app->deleteData($this->table, $key);
        redirect($this->control);
    }

}

/* End of file video.php */
/* Location: ./application/controllers/video.php */