From ebb7251c76bdb51bdb18c48f60b26682e4b930d0 Mon Sep 17 00:00:00 2001 From: Daeng Rosanda Date: Tue, 3 Sep 2024 19:43:44 +0700 Subject: [PATCH] FEAT: #12 enrich search result --- .github/workflows/php.yml | 30 ++++++++++++++++++++++++++++++ app/model/api/d_provinsi_model.php | 17 +++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/php.yml diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..1e50fd6 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,30 @@ +name: PHP Lint Check + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + + - name: PHP lint + run: | + lint_errors=$(find app -type f -name "*.php" -exec php -l {} \; 2>&1) + echo "$lint_errors" + if grep -q "Parse error" <<< "$lint_errors"; then + exit 1 + fi diff --git a/app/model/api/d_provinsi_model.php b/app/model/api/d_provinsi_model.php index 561e3f9..e2947a7 100644 --- a/app/model/api/d_provinsi_model.php +++ b/app/model/api/d_provinsi_model.php @@ -1,5 +1,5 @@ db->order_by("$this->tbl_as.nama", "asc"); return $this->db->get('', 0); } + private function join_zipcode() + { + $composites = [ + $this->db->composite_create("$this->tbl3_as.id", "=", "$this->tbl6_as.d_kabkota_id", "AND", 1, 0), + $this->db->composite_create("$this->tbl4_as.id", "=", "$this->tbl6_as.d_kecamatan_id", "AND", 0, 1) + ]; + + return $composites; + } public function cari($keyword) { $this->db->select_as("$this->tbl2_as.nama", "negara", 0); @@ -119,23 +128,27 @@ public function cari($keyword) $this->db->select_as("$this->tbl3_as.nama", "kabkota", 0); $this->db->select_as("$this->tbl4_as.nama", "kecamatan", 0); $this->db->select_as("$this->tbl5_as.nama", "desakel", 0); + $this->db->select_as("$this->tbl6_as.kodepos", "kodepos", 0); $this->db->from($this->tbl, $this->tbl_as); $this->db->join($this->tbl2, $this->tbl2_as, 'nation_code', $this->tbl_as, 'd_negara_nation_code', ''); $this->db->join($this->tbl3, $this->tbl3_as, 'd_provinsi_id', $this->tbl_as, 'id', ''); $this->db->join($this->tbl4, $this->tbl4_as, 'd_kabkota_id', $this->tbl3_as, 'id', ''); $this->db->join($this->tbl5, $this->tbl5_as, 'd_kecamatan_id', $this->tbl4_as, 'id', ''); + $this->db->join_composite($this->tbl6, $this->tbl6_as, $this->join_zipcode(), ''); if (strlen($keyword)>0) { $this->db->where_as("$this->tbl_as.nama", $keyword, 'OR', 'like%%', 1, 0); $this->db->where_as("$this->tbl2_as.nama", $keyword, 'OR', 'like%%', 0, 0); $this->db->where_as("$this->tbl3_as.nama", $keyword, 'OR', 'like%%', 0, 0); $this->db->where_as("$this->tbl4_as.nama", $keyword, 'OR', 'like%%', 0, 0); - $this->db->where_as("$this->tbl5_as.nama", $keyword, 'OR', 'like%%', 0, 1); + $this->db->where_as("$this->tbl5_as.nama", $keyword, 'OR', 'like%%', 0, 0); + $this->db->where_as("$this->tbl6_as.kodepos", $keyword, 'OR', 'like%%', 0, 1); } $this->db->order_by("$this->tbl_as.nama", "asc"); $this->db->order_by("$this->tbl3_as.nama", "asc"); $this->db->order_by("$this->tbl4_as.nama", "asc"); $this->db->order_by("$this->tbl5_as.nama", "asc"); + $this->db->order_by("$this->tbl6_as.kodepos", "asc"); return $this->db->get('', 0); } }