%PDF-1.4
Directory : /var/www/vhosts/lautnusantara.com/httpdocs/mis/app/Models/ |
<?php namespace App\Models; use CodeIgniter\Model; class Menu_Model extends Model { protected $table = 'ssn_menu'; protected $primaryKey = 'id'; public function get_menu($parent_id, $user_id = false) { $builder = $this->db->table('ssn_menu'); // if($user_id!=false){ $builder->select('ssn_menu.*,ssn_user_menu_map.user_id'); $builder->join('ssn_user_menu_map', 'ssn_user_menu_map.user_id="' . $user_id . '" and ssn_user_menu_map.menu_id=ssn_menu.id and ssn_user_menu_map.active=1 and ssn_user_menu_map.trash=0'); // $builder->where('ssn_user_menu_map.user_id!=null'); // } else { // $builder->select('ssn_menu.*'); // } $builder->where('ssn_menu.parent_id', $parent_id); $builder->where('ssn_menu.active', '1'); $builder->where('ssn_menu.trash', '0'); $builder->orderBy('sortir', 'ASC'); return $builder->get(); } public function get_parent_menu() { $builder = $this->db->table('ssn_menu'); $builder->select('*'); $builder->where('ssn_menu.have_child', 1); $builder->where('ssn_menu.active', '1'); $builder->where('ssn_menu.trash', '0'); $builder->orderBy('sortir', 'ASC'); return $builder->get(); } public function get_all_menu($type_id = false) { $builder = $this->db->table('ssn_menu'); $builder->select('*'); if ($type_id) { $builder->where('ssn_menu.id_menu_types', $type_id); } // $builder->where('ssn_menu.active','1'); $builder->where('ssn_menu.trash', '0'); $builder->orderBy('typemenu_id,sortir', 'ASC'); return $builder->get(); } public function get_detail_menu($id = false) { $builder = $this->db->table('ssn_menu'); $builder->select('*'); if ($id) { $builder->where('ssn_menu.id', $id); } $builder->where('ssn_menu.trash', '0'); // $builder->orderBy('sortir', 'ASC'); return $builder->get(); } public function save_menu($data) { $query = $this->db->table('ssn_menu')->insert($data); return $query; } public function update_menu($data, $id) { $query = $this->db->table('ssn_menu')->update($data, array('id' => $id)); return $query; } public function delete_menu($data, $id) { $query = $this->db->table('ssn_menu')->update($data, array('id' => $id)); return $query; } } ?>