Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/serbaantik.com/public_html/application/controllers/api/ |
Upload File : |
<?PHP defined('BASEPATH') or exit('No direct script access allowed'); use chriskacerguis\RestServer\RestController; class Suggestion extends RestController { function __construct() { parent::__construct(); } public function index_get() { $type = $this->get('type'); $inquiry = $this->get('inquiry'); if(!$type) { $this->response([ 'status' => false, 'message' => 'missing parameters' ], 400); } switch ($type) { case 'collection': if(empty($inquiry)) { $result = array(); } else { $result = $this->db->select('id, name')->from('collections_master')->like('name', $inquiry)->limit(10)->get()->result_array(); } break; case 'pattern': if(empty($inquiry)) { $result = array(); } else { $result = $this->db->select('id, name')->from('patterns_master')->like('name', $inquiry)->limit(10)->get()->result_array(); } break; case 'color': if(empty($inquiry)) { $result = array(); } else { $result = $this->db->select('id, name')->from('colors_master')->like('name', $inquiry)->limit(10)->get()->result_array(); } break; case 'usage': if(empty($inquiry)) { $result = array(); } else { $result = $this->db->select('id, name')->from('usages_master')->like('name', $inquiry)->limit(10)->get()->result_array(); } break; default: # code... break; } $this->response([ 'status' => true, 'data' => $result ], 200); } public function getid_get() { $collection = $this->get('collection'); $data = $this->db->select('id')->from('collections_master')->where('name', $collection)->get()->row_array(); if(!$data) { $this->response([ 'status' => false, 'message' => 'Collection not found' ], 404); } $this->response([ 'status' => true, 'id' => $data['id'] ], 200); } }