Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: #12 enrich search result #13

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 15 additions & 2 deletions app/model/api/d_provinsi_model.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
class D_Provinsi_Model extends SENE_Model
class D_Provinsi_Model extends \SENE_Model
{
public $tbl = 'd_provinsi';
public $tbl_as = 'dp';
Expand Down Expand Up @@ -112,30 +112,43 @@ public function getSearch($nation_code, $negara_nama, $keyword="")
$this->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);
$this->db->select_as("$this->tbl_as.nama", "provinsi", 0);
$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);
}
}