Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class SkillController extends CI_Controller {
- protected $data;
- public function __construct()
- {
- parent::__construct();
- $this->load->model('Skill');
- }
- public function RestData()
- {
- $list = $this->Skill->get_datatables(); //Using CI_Model
- $data = array();
- $no = @$_POST['start'];
- foreach ($list as $res) {
- $no++;
- //Define Button
- $allButton = "";
- $buttonEdit = "<button type='button' onclick='get_data(\"".$res->id_skill."\")'>Edit</button>";
- $buttonDelete = "<button type='button' onclick='delete_data(\"".$res->id_skill."\")'>Delete</button>";
- $allButton .= $buttonEdit;
- $allButton .= $buttonDelete;
- $row = array();
- $row[] = $allButton;
- $row[] = $res->nama_keahlian;
- $data[] = $row;
- }
- $output = array(
- "draw" => @$_POST['draw'],
- "recordsTotal" => $this->Keahlian->count_all(),
- "recordsFiltered" => $this->Keahlian->count_filtered(),
- "data" => $data,
- );
- // output to json format
- echo json_encode($output);
- }
- public function DetailData()
- $req = $this->input->post();
- $id = $req['id_parameter'];
- $data = Skill::where('id_skill', $id)->first(); //Using Eloquent
- echo json_encode(['id' => $data->id_skill, 'skill' => $data->skill_name ]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment