@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('ro_province', function (Blueprint $table) { |
|
16 | + Schema::create('ro_province', function(Blueprint $table) { |
|
17 | 17 | $table->string('province_id', 20)->primary(); |
18 | 18 | $table->string('province', 255)->nullable(); |
19 | 19 | $table->timestamps(); |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('ro_city', function (Blueprint $table) { |
|
16 | + Schema::create('ro_city', function(Blueprint $table) { |
|
17 | 17 | $table->string('city_id', 20)->primary(); |
18 | 18 | $table->string('province_id', 20); |
19 | 19 | $table->string('province', 120)->nullable(); |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -Route::get('raja-ongkir', function () { |
|
3 | +Route::get('raja-ongkir', function() { |
|
4 | 4 | dd(RajaOngkir::getProvince()); |
5 | 5 | }); |
@@ -39,23 +39,23 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function handle() |
41 | 41 | { |
42 | - if($this->argument('name') == "all"){ |
|
42 | + if ($this->argument('name') == "all") { |
|
43 | 43 | $this->all(); |
44 | - } elseif($this->argument('name') == "city"){ |
|
44 | + } elseif ($this->argument('name') == "city") { |
|
45 | 45 | RajaOngkir::cachingCity(); |
46 | - } elseif($this->argument('name') == "province"){ |
|
46 | + } elseif ($this->argument('name') == "province") { |
|
47 | 47 | RajaOngkir::cachingProvince(); |
48 | - } elseif($this->argument('name') == "subdistrict"){ |
|
48 | + } elseif ($this->argument('name') == "subdistrict") { |
|
49 | 49 | RajaOngkir::cachingSubDistrict(); |
50 | - } elseif($this->argument('name') == "clear"){ |
|
50 | + } elseif ($this->argument('name') == "clear") { |
|
51 | 51 | CacheCMD::clearCache(); |
52 | - } elseif($this->argument('name') == "refresh"){ |
|
52 | + } elseif ($this->argument('name') == "refresh") { |
|
53 | 53 | CacheCMD::refresh(); |
54 | - } else{ |
|
54 | + } else { |
|
55 | 55 | $this->line('<fg=yellow>valid input is all, clear, refresh, city, province and subdistrict.'); |
56 | 56 | } |
57 | 57 | } |
58 | - private function all(){ |
|
58 | + private function all() { |
|
59 | 59 | $this->line("|_ _| / _| | ___ \ (_) | _ | | | (_) |
60 | 60 | | | _ __| |_ __ _ ______ | |_/ /__ _ _ __ _ | | | |_ __ __ _| | ___ _ __ |
61 | 61 | | || '__| _/ _` | |______| | // _` | |/ _` | | | | | '_ \ / _` | |/ / | '__| |
@@ -68,18 +68,18 @@ discard block |
||
68 | 68 | echo"---------------------".PHP_EOL; |
69 | 69 | RajaOngkir::cachingProvince(); |
70 | 70 | echo PHP_EOL."---------------------".PHP_EOL; |
71 | - sleep(1);//Cooling Down |
|
71 | + sleep(1); //Cooling Down |
|
72 | 72 | echo"City Caching".PHP_EOL; |
73 | 73 | echo "---------------------".PHP_EOL; |
74 | 74 | RajaOngkir::cachingCity(); |
75 | 75 | echo PHP_EOL."---------------------".PHP_EOL; |
76 | - sleep(1);//Cooling Down |
|
76 | + sleep(1); //Cooling Down |
|
77 | 77 | echo"Subdistrict Caching".PHP_EOL; |
78 | 78 | echo "---------------------".PHP_EOL; |
79 | 79 | RajaOngkir::cachingSubDistrict(); |
80 | 80 | echo PHP_EOL."---------------------".PHP_EOL; |
81 | 81 | } |
82 | - private function refresh(){ |
|
82 | + private function refresh() { |
|
83 | 83 | echo "---------------------".PHP_EOL; |
84 | 84 | echo"Refresh Cache".PHP_EOL; |
85 | 85 | echo"---------------------".PHP_EOL; |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | echo"---------------------".PHP_EOL; |
90 | 90 | RajaOngkir::cachingProvince(); |
91 | 91 | echo PHP_EOL."---------------------".PHP_EOL; |
92 | - sleep(1);//Cooling Down |
|
92 | + sleep(1); //Cooling Down |
|
93 | 93 | echo"City Caching".PHP_EOL; |
94 | 94 | echo "---------------------".PHP_EOL; |
95 | 95 | RajaOngkir::cachingCity(); |
96 | 96 | echo PHP_EOL."---------------------".PHP_EOL; |
97 | - sleep(1);//Cooling Down |
|
97 | + sleep(1); //Cooling Down |
|
98 | 98 | echo"Subdistrict Caching".PHP_EOL; |
99 | 99 | echo "---------------------".PHP_EOL; |
100 | 100 | RajaOngkir::cachingSubDistrict(); |
@@ -13,14 +13,14 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('ro_subdistrict', function (Blueprint $table) { |
|
17 | - $table->string('subdistrict_id',20)->primary(); |
|
18 | - $table->string('province_id',20); |
|
19 | - $table->string('province',120)->nullable(); |
|
20 | - $table->string('city_id',20)->nullable(); |
|
21 | - $table->string('city',128)->nullable(); |
|
22 | - $table->string('type',60)->nullable(); |
|
23 | - $table->string('subdistrict_name',160)->nullable(); |
|
16 | + Schema::create('ro_subdistrict', function(Blueprint $table) { |
|
17 | + $table->string('subdistrict_id', 20)->primary(); |
|
18 | + $table->string('province_id', 20); |
|
19 | + $table->string('province', 120)->nullable(); |
|
20 | + $table->string('city_id', 20)->nullable(); |
|
21 | + $table->string('city', 128)->nullable(); |
|
22 | + $table->string('type', 60)->nullable(); |
|
23 | + $table->string('subdistrict_name', 160)->nullable(); |
|
24 | 24 | $table->timestamps(); |
25 | 25 | }); |
26 | 26 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | $fill = ['city_id'=>$r->city_id, 'province_id'=>$r->province_id, 'province' => $r->province, 'type'=>$r->type, 'city_name'=>$r->city_name, 'postal_code'=>$r->postal_code]; |
27 | 27 | $where = ['city_id' => $r->city_id]; |
28 | 28 | } elseif ($type == 'subdistrict') { |
29 | - $fill = ['subdistrict_id'=>$r->subdistrict_id, 'province_id'=>$r->province_id, 'province' => $r->province, 'city_id'=>$r->city_id, 'city'=>$r->city, 'type'=>$r->type,'subdistrict_name'=>$r->subdistrict_name]; |
|
29 | + $fill = ['subdistrict_id'=>$r->subdistrict_id, 'province_id'=>$r->province_id, 'province' => $r->province, 'city_id'=>$r->city_id, 'city'=>$r->city, 'type'=>$r->type, 'subdistrict_name'=>$r->subdistrict_name]; |
|
30 | 30 | $where = ['subdistrict_id' => $r->subdistrict_id]; |
31 | 31 | } |
32 | 32 | if (DB::table(self::$table_DB)->where($where)->count() == 0) { |
@@ -38,40 +38,40 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function handle() |
40 | 40 | { |
41 | - if($this->argument('name') == "all"){ |
|
41 | + if ($this->argument('name') == "all") { |
|
42 | 42 | $this->all(); |
43 | - } elseif($this->argument('name') == "city"){ |
|
43 | + } elseif ($this->argument('name') == "city") { |
|
44 | 44 | RajaOngkir::cachingCity(); |
45 | - } elseif($this->argument('name') == "province"){ |
|
45 | + } elseif ($this->argument('name') == "province") { |
|
46 | 46 | RajaOngkir::cachingProvince(); |
47 | - } elseif($this->argument('name') == "subdistrict"){ |
|
47 | + } elseif ($this->argument('name') == "subdistrict") { |
|
48 | 48 | RajaOngkir::cachingSubDistrict(); |
49 | - } elseif($this->argument('name') == "clear"){ |
|
49 | + } elseif ($this->argument('name') == "clear") { |
|
50 | 50 | ROCache::clearCache(); |
51 | - } elseif($this->argument('name') == "refresh"){ |
|
51 | + } elseif ($this->argument('name') == "refresh") { |
|
52 | 52 | ROCache::refresh(); |
53 | - } else{ |
|
53 | + } else { |
|
54 | 54 | $this->line('<fg=yellow>Valid input is all, clear, refresh, city, province and subdistrict.'); |
55 | 55 | } |
56 | 56 | } |
57 | - private function all(){ |
|
57 | + private function all() { |
|
58 | 58 | echo "---------------------".PHP_EOL; |
59 | 59 | echo"Province Caching".PHP_EOL; |
60 | 60 | echo"---------------------".PHP_EOL; |
61 | 61 | RajaOngkir::cachingProvince(); |
62 | 62 | echo PHP_EOL."---------------------".PHP_EOL; |
63 | - sleep(1);//Cooling Down |
|
63 | + sleep(1); //Cooling Down |
|
64 | 64 | echo"City Caching".PHP_EOL; |
65 | 65 | echo "---------------------".PHP_EOL; |
66 | 66 | RajaOngkir::cachingCity(); |
67 | 67 | echo PHP_EOL."---------------------".PHP_EOL; |
68 | - sleep(1);//Cooling Down |
|
68 | + sleep(1); //Cooling Down |
|
69 | 69 | echo"Subdistrict Caching".PHP_EOL; |
70 | 70 | echo "---------------------".PHP_EOL; |
71 | 71 | RajaOngkir::cachingSubDistrict(); |
72 | 72 | echo PHP_EOL."---------------------".PHP_EOL; |
73 | 73 | } |
74 | - private function refresh(){ |
|
74 | + private function refresh() { |
|
75 | 75 | echo "---------------------".PHP_EOL; |
76 | 76 | echo"Refresh Cache".PHP_EOL; |
77 | 77 | echo"---------------------".PHP_EOL; |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | echo"---------------------".PHP_EOL; |
82 | 82 | RajaOngkir::cachingProvince(); |
83 | 83 | echo PHP_EOL."---------------------".PHP_EOL; |
84 | - sleep(1);//Cooling Down |
|
84 | + sleep(1); //Cooling Down |
|
85 | 85 | echo"City Caching".PHP_EOL; |
86 | 86 | echo "---------------------".PHP_EOL; |
87 | 87 | RajaOngkir::cachingCity(); |
88 | 88 | echo PHP_EOL."---------------------".PHP_EOL; |
89 | - sleep(1);//Cooling Down |
|
89 | + sleep(1); //Cooling Down |
|
90 | 90 | echo"Subdistrict Caching".PHP_EOL; |
91 | 91 | echo "---------------------".PHP_EOL; |
92 | 92 | RajaOngkir::cachingSubDistrict(); |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function handle() |
40 | 40 | { |
41 | - if($this->argument('cmd') == "version" || $this->argument('cmd') == "v" ){ |
|
41 | + if ($this->argument('cmd') == "version" || $this->argument('cmd') == "v") { |
|
42 | 42 | $this->informasi(); |
43 | - } elseif($this->argument('cmd') == "key"){ |
|
43 | + } elseif ($this->argument('cmd') == "key") { |
|
44 | 44 | $this->line('Api Key: '.config('irfa.rajaongkir.api_key')); |
45 | - } elseif($this->argument('cmd') == "type"){ |
|
45 | + } elseif ($this->argument('cmd') == "type") { |
|
46 | 46 | $this->line('Account Type: '.config('irfa.rajaongkir.account_type')); |
47 | - } elseif($this->argument('cmd') == "info"){ |
|
47 | + } elseif ($this->argument('cmd') == "info") { |
|
48 | 48 | $this->informasi(); |
49 | 49 | $this->line('-------------------------------------------------------------------------------'); |
50 | 50 | $this->line('Account Type: '.config('irfa.rajaongkir.account_type')); |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | $this->line('City Table: '.config('irfa.rajaongkir.city_table')); |
55 | 55 | $this->line('Subdistrict Table: '.config('irfa.rajaongkir.subdistrict_table')); |
56 | 56 | $this->line('Cache Type: '.config('irfa.rajaongkir.cache_type')); |
57 | - } else{ |
|
57 | + } else { |
|
58 | 58 | $this->line('<fg=yellow>valid input is version, key, type, info,and v.'); |
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | - private function informasi(){ |
|
62 | + private function informasi() { |
|
63 | 63 | $this->line(" |_ _| / _| | __ \ (_) / __ \ | | (_) |
64 | 64 | | | _ __| |_ __ _ ______ | |__) |__ _ _ __ _ | | | |_ __ __ _| | ___ _ __ |
65 | 65 | | | | '__| _/ _` | |______| | _ // _` | |/ _` | | | | | '_ \ / _` | |/ / | '__| |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | -private static function exceptCurl($err){ |
|
248 | - if(php_sapi_name() == "cli"){ |
|
247 | +private static function exceptCurl($err) { |
|
248 | + if (php_sapi_name() == "cli") { |
|
249 | 249 | echo "Can't connect to server, please check your internet connection.\n"; |
250 | 250 | echo "Exception: \033[31m".$err; |
251 | 251 | exit(); |
252 | - } else{ |
|
252 | + } else { |
|
253 | 253 | throw new Exception($err); |
254 | 254 | } |
255 | 255 | } |
@@ -285,17 +285,17 @@ discard block |
||
285 | 285 | return $result; |
286 | 286 | } else { |
287 | 287 | $data = json_decode($response, false); |
288 | - if(!empty($data)){ |
|
288 | + if (!empty($data)) { |
|
289 | 289 | $json = $data->rajaongkir; |
290 | 290 | if ($json->status->code == '400') { |
291 | - $result = ['res' => $json->status->code,'success'=> false]; |
|
291 | + $result = ['res' => $json->status->code, 'success'=> false]; |
|
292 | 292 | return $result; |
293 | 293 | } else { |
294 | - $result = ['res' => "Connected to server.",'success'=> true]; |
|
294 | + $result = ['res' => "Connected to server.", 'success'=> true]; |
|
295 | 295 | return $result; |
296 | 296 | } |
297 | - } else{ |
|
298 | - $result = ['res' => "Data is Empty.",'success'=> false]; |
|
297 | + } else { |
|
298 | + $result = ['res' => "Data is Empty.", 'success'=> false]; |
|
299 | 299 | return $result; |
300 | 300 | } |
301 | 301 | } |