load->model('sejarah_model'); is_logged_in(); } public function index() { $data['title'] = 'Sejarah'; $data['sejarah'] = $this->sejarah_model->get_data('tb_sejarah')->result(); $data['admin'] = $this->db->get_where('admin', ['email' => $this->session->userdata('email')])->row_array(); $this->load->view('templates/header', $data); $this->load->view('templates/sidebar', $data); $this->load->view('admin/sejarah'); $this->load->view('templates/footer'); } public function tambah_aksi() { $this->_rules(); if ($this->form_validation->run() == TRUE) { $data = array( 'sejarah' => $this->input->post('sejarah'), ); $this->sejarah_model->insert_data($data, 'tb_sejarah'); $this->session->set_flashdata('pesan', ''); redirect('sejarah'); } } public function edit($id_sejarah) { $this->_rules(); if ($this->form_validation->run() == FALSE) { $this->index(); } else { $data = array( 'id_sejarah' => $id_sejarah, 'sejarah' => $this->input->post('sejarah'), ); $this->sejarah_model->update_data($data, 'tb_sejarah'); $this->session->set_flashdata('pesan', ''); redirect('sejarah'); } } public function _rules() { $this->form_validation->set_rules('sejarah', 'Sejarah', 'required', array( 'required' => '%s harus diisi!!' )); } public function delete($id) { $where = array('id_sejarah' => $id); $this->sejarah_model->delete($where, 'tb_sejarah'); $this->session->set_flashdata('pesan', ''); redirect('sejarah'); } }