Update Api untuk Contacts CRM
This commit is contained in:
parent
b2bd7975db
commit
d95e2fd833
@ -257,12 +257,13 @@ $routes->group('', ['filter' => 'cors'], function($routes) {
|
||||
|
||||
// REST API
|
||||
$routes->get('/api/zones', 'Api\ZonesApi::getAll');
|
||||
$routes->get('/api/contacts', 'Api\ContactsApi::getAll');
|
||||
// $routes->get('/api/provinces', 'Api\ZonesApi::getProvinces');
|
||||
// $routes->get('/api/cities', 'Api\ZonesApi::getCities');
|
||||
$routes->get('/api/getProductAlias', 'Api::getProductAlias');
|
||||
$routes->get('/api/getProductSites', 'Api::getProductSites');
|
||||
$routes->get('/api/getProvinces', 'Api::getProvinces');
|
||||
$routes->get('/api/getCities', 'Api::getCities');
|
||||
// $routes->get('/api/getProvinces', 'Api::getProvinces');
|
||||
// $routes->get('/api/getCities', 'Api::getCities');
|
||||
|
||||
|
||||
//CLQMS
|
||||
|
||||
47
app/Controllers/Api/ContactsApi.php
Normal file
47
app/Controllers/Api/ContactsApi.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
namespace App\Controllers\Api;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\ContactsModel;
|
||||
|
||||
class ContactsApi extends BaseController {
|
||||
use ResponseTrait;
|
||||
|
||||
protected $model;
|
||||
|
||||
public function __construct() {
|
||||
$this->model = new ContactsModel();
|
||||
}
|
||||
|
||||
public function getAll() {
|
||||
$rows = $this->model->getAll();
|
||||
|
||||
if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => [] ], 200); }
|
||||
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
||||
}
|
||||
|
||||
// public function getProvinces() {
|
||||
// // $filters = [
|
||||
// // 'zoneid' => $this->request->getVar('zoneid') ?? null,
|
||||
// // 'zonename' => $this->request->getVar('zonename') ?? null
|
||||
// // ];
|
||||
|
||||
// $rows = $this->model->getAllProvinces();
|
||||
|
||||
// if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => [] ], 200); }
|
||||
// return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
||||
// }
|
||||
|
||||
// public function getCities() {
|
||||
|
||||
// $filter = [
|
||||
// 'zoneid' => $this->request->getVar('zoneid') ?? null
|
||||
// ];
|
||||
|
||||
// $rows = $this->model->getAllCities($filter);
|
||||
|
||||
// if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => [] ], 200); }
|
||||
// return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
||||
// }
|
||||
}
|
||||
@ -8,4 +8,8 @@ class ContactsModel extends Model {
|
||||
protected $allowedFields = [
|
||||
'firstname', 'lastname', 'title', 'initial', 'birthdate', 'email_1', 'email_2', 'phone', 'mobile_1', 'mobile_2', 'createdate', 'enddate'
|
||||
];
|
||||
|
||||
public function getAll() {
|
||||
return $this->findAll();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user