diff --git a/.env.docker b/.env.docker index fedbeed..ea8375c 100644 --- a/.env.docker +++ b/.env.docker @@ -4,6 +4,8 @@ APP_KEY=WbPGkYNmXZ6ZQplGlvl0iZ7zyW1b09xa APP_DEBUG=true APP_URL=http://localhost APP_TIMEZONE=Asia/Kuala_Lumpur +API_ARRAHNBID=http://lelong.test/api/ +API_ARRAHNBID_ANNUR=http://lelong-annur.test/api/ LOG_CHANNEL=stack LOG_LEVEL=debug diff --git a/.env.example b/.env.example index a4e9ab2..9f8a734 100644 --- a/.env.example +++ b/.env.example @@ -5,6 +5,7 @@ APP_DEBUG=true APP_URL=http://api_arrahn.test APP_TIMEZONE=Asia/Kuala_Lumpur API_ARRAHNBID=http://lelong.test/api/ +API_ARRAHNBID_ANNUR=http://lelong-annur.test/api/ LOG_CHANNEL=stack LOG_SLACK_WEBHOOK_URL= diff --git a/.env.production b/.env.production index e218148..90443a6 100644 --- a/.env.production +++ b/.env.production @@ -4,6 +4,8 @@ APP_KEY=WbPGkYNmXZ6ZQplGlvl0iZ7zyW1b09xa APP_DEBUG=false APP_URL=https://apiujrah.erahn.com.my APP_TIMEZONE=Asia/Kuala_Lumpur +API_ARRAHNBID=https://adminbid-kopkb.erahn.com.my/api/ +API_ARRAHNBID_ANNUR=https://adminbid-annur.erahn.com.my/api/ LOG_CHANNEL=stack LOG_SLACK_WEBHOOK_URL= diff --git a/.env.tukar b/.env.tukar deleted file mode 100644 index e2fe920..0000000 --- a/.env.tukar +++ /dev/null @@ -1,244 +0,0 @@ -APP_NAME=Lumen -APP_ENV=local -APP_KEY=WbPGkYNmXZ6ZQplGlvl0iZ7zyW1b09xa -APP_DEBUG=false -APP_URL=https://api.arrahn.com.my -APP_TIMEZONE=Asia/Kuala_Lumpur - - -LOG_CHANNEL=stack -LOG_SLACK_WEBHOOK_URL= - -DB_CONNECTION=mysql -DB_HOST=172.16.4.102 -DB_PORT=3306 -DB_DATABASE=arrahn_kb2 -DB_USERNAME=zone2 -DB_PASSWORD=G0dz!ll4@2020 - -DB_CONNECTION_2=mysql -DB_HOST_2=172.16.4.102 -DB_PORT_2=3306 -DB_DATABASE_2=arrahn_wcy -DB_USERNAME_2=zone2 -DB_PASSWORD_2=G0dz!ll4@2020 - -DB_CONNECTION_3=mysql -DB_HOST_3=172.16.4.102 -DB_PORT_3=3306 -DB_DATABASE_3=arrahn_1stop -DB_USERNAME_3=zone2 -DB_PASSWORD_3=G0dz!ll4@2020 - -DB_CONNECTION_4=mysql -DB_HOST_4=172.16.4.102 -DB_PORT_4=3306 -DB_DATABASE_4=arrahn_jlwt -DB_USERNAME_4=zone2 -DB_PASSWORD_4=G0dz!ll4@2020 - -DB_CONNECTION_5=mysql -DB_HOST_5=172.16.4.102 -DB_PORT_5=3306 -DB_DATABASE_5=arrahn_wb -DB_USERNAME_5=zone2 -DB_PASSWORD_5=G0dz!ll4@2020 - -DB_CONNECTION_6=mysql -DB_HOST_6=172.16.4.102 -DB_PORT_6=3306 -DB_DATABASE_6=arrahn_kls -DB_USERNAME_6=zone2 -DB_PASSWORD_6=G0dz!ll4@2020 - -DB_CONNECTION_7=mysql -DB_HOST_7=172.16.4.102 -DB_PORT_7=3306 -DB_DATABASE_7=online_arrahn -DB_USERNAME_7=zone2 -DB_PASSWORD_7=G0dz!ll4@2020 - -DB_CONNECTION_8=mysql -DB_HOST_8=172.16.4.102 -DB_PORT_8=3306 -DB_DATABASE_8=arrahn_pp -DB_USERNAME_8=zone2 -DB_PASSWORD_8=G0dz!ll4@2020 - -DB_CONNECTION_9=mysql -DB_HOST_9=172.16.4.102 -DB_PORT_9=3306 -DB_DATABASE_9=arrahn_mace -DB_USERNAME_9=zone2 -DB_PASSWORD_9=G0dz!ll4@2020 - -DB_CONNECTION_10=mysql -DB_HOST_10=172.16.4.102 -DB_PORT_10=3306 -DB_DATABASE_10=arrahn_pm -DB_USERNAME_10=zone2 -DB_PASSWORD_10=G0dz!ll4@2020 - -DB_CONNECTION_11=mysql -DB_HOST_11=172.16.4.102 -DB_PORT_11=3306 -DB_DATABASE_11=arrahn_gm -DB_USERNAME_11=zone2 -DB_PASSWORD_11=G0dz!ll4@2020 - -DB_CONNECTION_12=mysql -DB_HOST_12172.16.4.102 -DB_PORT_12=3306 -DB_DATABASE_12=arrahn_gcl -DB_USERNAME_12=zone2 -DB_PASSWORD_12=G0dz!ll4@2020 - -DB_CONNECTION_13=mysql -DB_HOST_13=172.16.4.102 -DB_PORT_13=3306 -DB_DATABASE_13=arrahn_jli -DB_USERNAME_13=zone2 -DB_PASSWORD_13=G0dz!ll4@2020 - -DB_CONNECTION_14=mysql -DB_HOST_14=172.16.4.102 -DB_PORT_14=3306 -DB_DATABASE_14=arrahn_rp -DB_USERNAME_14=zone2 -DB_PASSWORD_14=G0dz!ll4@2020 - -DB_CONNECTION_15=mysql -DB_HOST_15=172.16.4.102 -DB_PORT_15=3306 -DB_DATABASE_15=arrahn_ktn -DB_USERNAME_15=zone2 -DB_PASSWORD_15=G0dz!ll4@2020 - -DB_CONNECTION_16=mysql -DB_HOST_16=172.16.4.102 -DB_PORT_16=3306 -DB_DATABASE_16=arrahn_pg -DB_USERNAME_16=zone2 -DB_PASSWORD_16=G0dz!ll4@2020 - -DB_CONNECTION_17=mysql -DB_HOST_17=172.16.4.102 -DB_PORT_17=3306 -DB_DATABASE_17=arrahn_skudai -DB_USERNAME_17=zone2 -DB_PASSWORD_17=G0dz!ll4@2020 - -DB_CONNECTION_18=mysql -DB_HOST_18=172.16.4.102 -DB_PORT_18=3306 -DB_DATABASE_18=arrahn_pttn -DB_USERNAME_18=zone2 -DB_PASSWORD_18=G0dz!ll4@2020 - -DB_CONNECTION_19=mysql -DB_HOST_19=172.16.4.102 -DB_PORT_19=3306 -DB_DATABASE_19=arrahn_btg -DB_USERNAME_19=zone2 -DB_PASSWORD_19=G0dz!ll4@2020 - -DB_CONNECTION_20=mysql -DB_HOST_20=172.16.4.102 -DB_PORT_20=3306 -DB_DATABASE_20=arrahn_raub -DB_USERNAME_20=zone2 -DB_PASSWORD_20=G0dz!ll4@2020 - -DB_CONNECTION_21=mysql -DB_HOST_21=172.16.4.102 -DB_PORT_21=3306 -DB_DATABASE_21=arrahn_kgr -DB_USERNAME_21=zone2 -DB_PASSWORD_21=G0dz!ll4@2020 - -DB_CONNECTION_22=mysql -DB_HOST_22=172.16.4.102 -DB_PORT_22=3306 -DB_DATABASE_22=arrahn_sdk -DB_USERNAME_22=zone2 -DB_PASSWORD_22=G0dz!ll4@2020 - -DB_CONNECTION_23=mysql -DB_HOST_23=172.16.4.102 -DB_PORT_23=3306 -DB_DATABASE_23=arrahn_sp -DB_USERNAME_23=zone2 -DB_PASSWORD_23=G0dz!ll4@2020 - -DB_CONNECTION_24=mysql -DB_HOST_24=172.16.4.102 -DB_PORT_24=3306 -DB_DATABASE_24=arrahn_twu -DB_USERNAME_24=zone2 -DB_PASSWORD_24=G0dz!ll4@2020 - -DB_CONNECTION_25=mysql -DB_HOST_25=172.16.4.102 -DB_PORT_25=3306 -DB_DATABASE_25=arrahn_api2 -DB_USERNAME_25=zone2 -DB_PASSWORD_25=G0dz!ll4@2020 - -DB_CONNECTION_26=mysql -DB_HOST_26=172.16.4.102 -DB_PORT_26=3306 -DB_DATABASE_26=arrahn_kjg -DB_USERNAME_26=zone2 -DB_PASSWORD_26=G0dz!ll4@2020 - -DB_CONNECTION_27=mysql -DB_HOST_27=172.16.4.102 -DB_PORT_27=3306 -DB_DATABASE_27=arrahn_rl -DB_USERNAME_27=zone2 -DB_PASSWORD_27=G0dz!ll4@2020 - -DB_CONNECTION_28=mysql -DB_HOST_28=172.16.4.102 -DB_PORT_28=3306 -DB_DATABASE_28=arrahn_bfort -DB_USERNAME_28=zone2 -DB_PASSWORD_28=G0dz!ll4@2020 - -DB_CONNECTION_29=mysql -DB_HOST_29=172.16.4.102 -DB_PORT_29=3306 -DB_DATABASE_29=arrahn_kbelud -DB_USERNAME_29=zone2 -DB_PASSWORD_29=G0dz!ll4@2020 - -DB_CONNECTION_30=mysql -DB_HOST_30=172.16.4.102 -DB_PORT_30=3306 -DB_DATABASE_30=arrahn_tuaran -DB_USERNAME_30=zone2 -DB_PASSWORD_30=G0dz!ll4@2020 - -DB_CONNECTION_31=mysql -DB_HOST_31=172.16.4.102 -DB_PORT_31=3306 -DB_DATABASE_31=arrahn_kngau -DB_USERNAME_31=zone2 -DB_PASSWORD_31=G0dz!ll4@2020 - -DB_CONNECTION_32=mysql -DB_HOST_32=172.16.4.102 -DB_PORT_32=3306 -DB_DATABASE_32=arrahn_tm -DB_USERNAME_32=zone2 -DB_PASSWORD_32=G0dz!ll4@2020 - -DB_CONNECTION_33=mysql -DB_HOST_33=172.16.4.102 -DB_PORT_33=3306 -DB_DATABASE_33=arrahn_tmlh -DB_USERNAME_33=zone2 -DB_PASSWORD_33=G0dz!ll4@2020 - -CACHE_DRIVER=file -QUEUE_CONNECTION=sync diff --git a/app/Feature.php b/app/Feature.php index 1cccc7e..79efd1e 100644 --- a/app/Feature.php +++ b/app/Feature.php @@ -46,6 +46,28 @@ class Feature ]; } + /** + * Lelong portal base URL for this branch. rebet_annur branches (Annur/Tampoi) + * use API_ARRAHNBID_ANNUR; everyone else uses API_ARRAHNBID. + * + * Always returned with a trailing slash so callers can append 'portalApi'. + * + * @param string $kodcaw + * @return string + */ + public static function arrahnbidUrl($kodcaw) + { + $url = config('app_parameter.api_arrahnbid'); + if ($kodcaw && self::enabled($kodcaw, self::REBET_ANNUR)) { + $annur = config('app_parameter.api_arrahnbid_annur'); + if ($annur) { + $url = $annur; + } + } + + return rtrim((string) $url, '/') . '/'; + } + /** * Missing row is off (fail closed). * diff --git a/app/Http/Controllers/CawanganController.php b/app/Http/Controllers/CawanganController.php index f6f5df8..e01b692 100644 --- a/app/Http/Controllers/CawanganController.php +++ b/app/Http/Controllers/CawanganController.php @@ -26,6 +26,7 @@ class CawanganController extends Controller $data = $cawangan->toArray(); $data['features'] = Feature::mapFor($code_cawangan); + $data['api_arrahnbid'] = Feature::arrahnbidUrl($code_cawangan); return response()->json($data); } diff --git a/app/Http/Controllers/LelongController.php b/app/Http/Controllers/LelongController.php index d959f20..e2dbadb 100644 --- a/app/Http/Controllers/LelongController.php +++ b/app/Http/Controllers/LelongController.php @@ -11,6 +11,7 @@ use App\Negeri; use App\Lelong; use App\Transaction; use App\Cawangan; +use App\Feature; use App\Gadai; use App\TuntutBaki; use App\WTD; @@ -604,13 +605,7 @@ class LelongController extends Controller $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first(); if($cawangan['tagarrahnbid'] == 1){ - if(env('APP_ENV') != 'production'){ - $link = 'https://adminbid-kopkb.erahn.com.my/api/portalApi'; - }else{ - $link = 'https://adminbid-kopkb.erahn.com.my/api/portalApi'; - } - - $lelong = Http::withOptions(['verify' => true])->get($link,[ + $lelong = Http::withOptions(['verify' => true])->get(Feature::arrahnbidUrl($request->kodcaw).'portalApi',[ 'norujukan' => $request->norujukan ])->json(); $lelong = ($lelong != null) ? $lelong['lelong'] : []; @@ -656,7 +651,7 @@ class LelongController extends Controller $cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $request->kodcaw)->first(); if ($cawangan['tagarrahnbid'] == 0){ - $lelong = Http::withOptions(['verify' => true])->get(config('app_parameter.api_arrahnbid').'portalApi',[ + $lelong = Http::withOptions(['verify' => true])->get(Feature::arrahnbidUrl($request->kodcaw).'portalApi',[ 'norujukan' => $request->norujukan ])->json(); $lelong = ($lelong != null) ? $lelong['lelong'] : []; @@ -729,7 +724,7 @@ class LelongController extends Controller if($cawangan['tagarrahnbid'] == 1) { - $lelong = Http::withOptions(['verify' => true])->get(config('app_parameter.api_arrahnbid').'portalApi',['norujukan' => $request->norujukan])->json(); + $lelong = Http::withOptions(['verify' => true])->get(Feature::arrahnbidUrl($request->kodcaw).'portalApi',['norujukan' => $request->norujukan])->json(); $lelong = ($lelong != null) ? $lelong['lelong'] : []; }else{ $lelong = Lelong::on($cawangan['mysql'])->where([['norujukan',$request->norujukan]])->first(); diff --git a/config/app_parameter.php b/config/app_parameter.php index b9b4014..bf9e75b 100644 --- a/config/app_parameter.php +++ b/config/app_parameter.php @@ -3,6 +3,7 @@ return [ 'url' => env('APP_URL', 'http://localhost'), 'api_arrahnbid' => env('API_ARRAHNBID', 'http://lelong.test/api/'), + 'api_arrahnbid_annur' => env('API_ARRAHNBID_ANNUR', env('API_ARRAHNBID', 'http://lelong.test/api/')), 'api_v3' => env('API_V3', 'http://apiv3.localhost/api/') ];