<?php

namespace App\Controllers;

use App\Models\Model_status;

class status extends BaseController
{

    public function __construct()
    {
        $this->Model_status = new Model_status();
        helper('form');
    }

    public function index()
    {
        $data = array(
            'title' => 'status   ',
            'status' => $this->Model_status->all_data(),
            'isi'    => 'v_status'
        );
        return view('layout/v_wrapper', $data);
    }

    public function add()
    {
        $data = array('nama_status' => $this->request->getPost('nama_status'));
        $this->Model_status->add($data);
        session()->setFlashdata('pesan', 'Data Berhasil Di Tambahkan !!!');
        return redirect()->to(base_url('status'));
    }

    public function edit($id_status)
    {
        $data = array(
            'id_status' => $id_status,
            'nama_status' => $this->request->getPost('nama_status'),
        );
        $this->Model_status->edit($data);
        session()->setFlashdata('pesan', 'Data Berhasil Di Update !!!');
        return redirect()->to(base_url('status'));
    }

    public function delete($id_status)
    {
        $data = array(
            'id_status' => $id_status,
        );
        $this->Model_status->delete_data($data);
        session()->setFlashdata('pesan', 'Data Berhasil Di Hapus !!!');
        return redirect()->to(base_url('status'));
    }
    //--------------------------------------------------------------------

}
