66 lines
1.6 KiB
PHP
66 lines
1.6 KiB
PHP
<?php if (!defined('BASEPATH')) {
|
|
exit('No direct script access allowed');
|
|
}
|
|
|
|
class Phone_farm_phone_model extends CI_Model
|
|
{
|
|
public function __constructor()
|
|
{
|
|
parent::__constructor();
|
|
}
|
|
|
|
public function phone_farm_phone($data)
|
|
{
|
|
return (array) $data;
|
|
}
|
|
|
|
public function getPhones($params)
|
|
{
|
|
$res = AutomaticServerAPI::get('phone-farm-phones', $params);
|
|
|
|
if (isset($res['error'])) {
|
|
return ['success' => false, 'error' => $res['error']];
|
|
}
|
|
|
|
$data = array();
|
|
foreach ($res['data'] as $addr) {
|
|
$data[] = $this->parse_phone($addr);
|
|
}
|
|
|
|
$totalPage = isset($res['total']) ? $res['total'] : 0;
|
|
$page = isset($res['page']) ? $res['page'] : 0;
|
|
|
|
return [
|
|
'list' => $data,
|
|
'totalItems' => $totalPage,
|
|
'page' => $page,
|
|
];
|
|
}
|
|
|
|
public function getPhoneById($id) {
|
|
$res = AutomaticServerAPI::get("phone-farm-phones/$id", NULL);
|
|
$res['data'] = $this->parse_phone($res['data']);
|
|
return $res;
|
|
}
|
|
|
|
public function createPhone($params)
|
|
{
|
|
return AutomaticServerAPI::post('phone-farm-phones', $params);
|
|
}
|
|
|
|
public function removePhoneById($phoneId)
|
|
{
|
|
return AutomaticServerAPI::delete("phone-farm-phones/$phoneId");
|
|
}
|
|
|
|
public function updatePhoneById($phoneId, $params)
|
|
{
|
|
return AutomaticServerAPI::put("phone-farm-phones/$phoneId", $params);
|
|
}
|
|
|
|
private function parse_phone($originData)
|
|
{
|
|
return $this->phone_farm_phone($originData);
|
|
}
|
|
}
|