function amount_get() { $filters = $this->get("filter")["filters"]; $page = $this->get('page') !== false ? $this->get('page') : 1; $limit = $this->get('limit') !== false ? $this->get('limit') : 50; $sort = $this->get("sort"); $data["results"] = []; $data["count"] = 0; $obj = new Bill(null, $this->entity); //Sort if (!empty($sort) && isset($sort)) { foreach ($sort as $value) { $obj->order_by($value["field"], $value["dir"]); } } //Filter if (!empty($filters) && isset($filters)) { $deleted = 0; foreach ($filters as $value) { if (!empty($value["operator"]) && isset($value["operator"])) { if ($value["operator"] == "where_in") { $obj->where_in($value["field"], $value["value"]); } else { if ($value["operator"] == "or_where_in") { $obj->or_where_in($value["field"], $value["value"]); } else { if ($value["operator"] == "where_not_in") { $obj->where_not_in($value["field"], $value["value"]); } else { if ($value["operator"] == "or_where_not_in") { $obj->or_where_not_in($value["field"], $value["value"]); } else { if ($value["operator"] == "like") { $obj->like($value["field"], $value["value"]); } else { if ($value["operator"] == "or_like") { $obj->or_like($value["field"], $value["value"]); } else { if ($value["operator"] == "not_like") { $obj->not_like($value["field"], $value["value"]); } else { if ($value["operator"] == "or_not_like") { $obj->or_not_like($value["field"], $value["value"]); } else { if ($value["operator"] == "startswith") { $obj->like($value["field"], $value["value"], "after"); } else { if ($value["operator"] == "endswith") { $obj->like($value["field"], $value["value"], "before"); } else { if ($value["operator"] == "contains") { $obj->like($value["field"], $value["value"], "both"); } else { if ($value["operator"] == "or_where") { $obj->or_where($value["field"], $value["value"]); } else { $obj->where($value["field"] . ' ' . $value["operator"], $value["value"]); } } } } } } } } } } } } } else { if ($value["field"] == "deleted") { $deleted = $value["value"]; } else { $obj->where($value["field"], $value["value"]); } } } $obj->where("deleted", $deleted); } //Results $obj->select_sum("amount"); $obj->get(); $data["results"][] = floatval($obj->amount); //Response Data $this->response($data, 200); }