Advertisement
riandaka_

Untitled

Nov 28th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.86 KB | None | 0 0
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2.  
  3. class Workbook_model extends CI_Model
  4. {
  5.     private $_table = "workbook";
  6.  
  7.     public $workbook_id;
  8.     public $stage_id;
  9.     public $modul_id;
  10.     public $employee_id;
  11.     public $employee_name;
  12.     public $status;
  13.     public $image = "default.jpg";
  14.  
  15.     public function rules()
  16.     {
  17.         return [
  18.             ['field' => 'employee_name',
  19.             'label'  => 'Nama Pekerja',
  20.             'rules'  => 'required'],
  21.  
  22.             ['field' => 'status',
  23.              'label' => 'Status',
  24.              'rules' => 'required']
  25.         ];
  26.     }
  27.  
  28.     public function getAll()
  29.     {
  30.         return $this->db->get($this->_table)->result();
  31.     }
  32.  
  33.     public function getById($id)
  34.     {
  35.         return $this->db->get_where($this->_table, ["workbook_id" => $id]);
  36.     }
  37.  
  38.     public function save()
  39.     {
  40.         $post = $this->input->post();
  41.         $this->workbook_id = $post['workbook_id'];
  42.         $this->stage_id = $post['stage_id'];
  43.         $this->modul_id = $post['modul_id'];
  44.         $this->employee_id = $post['employee_id'];
  45.         $this->employee_name = $post['employee_name'];
  46.         $this->status = $post['status'];
  47.         $this->db->insert($this->_table, $this);
  48.     }
  49.    
  50.     public function update()
  51.     {
  52.         $post = $this->input->post();
  53.         $this->workbook_id = $post['workbook_id'];
  54.         $this->stage_id = $post['stage_id'];
  55.         $this->modul_id = $post['modul_id'];
  56.         $this->employee_id = $post['employee_id'];
  57.         $this->employee_name = $post['employee_name'];
  58.         $this->status = $post['status'];
  59.         $this->db->update($this->_table, $this, array('workbook_id' => $post['workbook_id']));
  60.     }
  61.  
  62.     public function delete($id)
  63.     {
  64.         return $this->db->delete($this->_table, array("workbook_id" => $id));
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement