Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- class Workbook_model extends CI_Model
- {
- private $_table = "workbook";
- public $workbook_id;
- public $stage_id;
- public $modul_id;
- public $employee_id;
- public $employee_name;
- public $status;
- public $image = "default.jpg";
- public function rules()
- {
- return [
- ['field' => 'employee_name',
- 'label' => 'Nama Pekerja',
- 'rules' => 'required'],
- ['field' => 'status',
- 'label' => 'Status',
- 'rules' => 'required']
- ];
- }
- public function getAll()
- {
- return $this->db->get($this->_table)->result();
- }
- public function getById($id)
- {
- return $this->db->get_where($this->_table, ["workbook_id" => $id]);
- }
- public function save()
- {
- $post = $this->input->post();
- $this->workbook_id = $post['workbook_id'];
- $this->stage_id = $post['stage_id'];
- $this->modul_id = $post['modul_id'];
- $this->employee_id = $post['employee_id'];
- $this->employee_name = $post['employee_name'];
- $this->status = $post['status'];
- $this->db->insert($this->_table, $this);
- }
- public function update()
- {
- $post = $this->input->post();
- $this->workbook_id = $post['workbook_id'];
- $this->stage_id = $post['stage_id'];
- $this->modul_id = $post['modul_id'];
- $this->employee_id = $post['employee_id'];
- $this->employee_name = $post['employee_name'];
- $this->status = $post['status'];
- $this->db->update($this->_table, $this, array('workbook_id' => $post['workbook_id']));
- }
- public function delete($id)
- {
- return $this->db->delete($this->_table, array("workbook_id" => $id));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement