<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Menu extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->library('form_validation');
        if (!$this->session->userdata('login')) {
            redirect('auth');
        }
        $this->load->model('menu_model');
    }

    public function index()
    {
        $data['menu'] = $this->menu_model->get_all_menu(date("Y-m-d"))->result_array();
        $this->load->view('menu/index', $data);
    }

    public function hapus($id_menu)
    {
        $this->menu_model->delete_menu($id_menu);

        $this->session->set_flashdata('pesan', '<div class="alert alert-success" role="alert">Data berhasil dihapus</div>');

        redirect('menu');
    }
}
