@@ -8,96 +8,96 @@ |
||
8 | 8 | |
9 | 9 | class ROCache extends Command |
10 | 10 | { |
11 | - /** |
|
12 | - * The name and signature of the console command. |
|
13 | - * |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - protected $signature = 'raja-ongkir:cache {name}'; |
|
11 | + /** |
|
12 | + * The name and signature of the console command. |
|
13 | + * |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + protected $signature = 'raja-ongkir:cache {name}'; |
|
17 | 17 | |
18 | - /** |
|
19 | - * The console command description. |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $description = 'Create cache RajaOngkir'; |
|
18 | + /** |
|
19 | + * The console command description. |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $description = 'Create cache RajaOngkir'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Create a new command instance. |
|
27 | - * |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public function __construct() |
|
31 | - { |
|
32 | - parent::__construct(); |
|
33 | - } |
|
25 | + /** |
|
26 | + * Create a new command instance. |
|
27 | + * |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public function __construct() |
|
31 | + { |
|
32 | + parent::__construct(); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Execute the console command. |
|
37 | - * |
|
38 | - * @return mixed |
|
39 | - */ |
|
40 | - public function handle() |
|
41 | - { |
|
42 | - if($this->argument('name') == "all"){ |
|
43 | - $this->all(); |
|
44 | - } elseif($this->argument('name') == "city"){ |
|
45 | - RajaOngkir::cachingCity(); |
|
46 | - } elseif($this->argument('name') == "province"){ |
|
47 | - RajaOngkir::cachingProvince(); |
|
48 | - } elseif($this->argument('name') == "subdistrict"){ |
|
49 | - RajaOngkir::cachingSubDistrict(); |
|
50 | - } elseif($this->argument('name') == "clear"){ |
|
51 | - CacheCMD::clearCache(); |
|
52 | - } elseif($this->argument('name') == "refresh"){ |
|
53 | - CacheCMD::refresh(); |
|
54 | - } else{ |
|
55 | - $this->line('<fg=yellow>valid input is all, clear, refresh, city, province and subdistrict.'); |
|
56 | - } |
|
57 | - } |
|
58 | - private function all(){ |
|
59 | - $this->line("|_ _| / _| | ___ \ (_) | _ | | | (_) |
|
35 | + /** |
|
36 | + * Execute the console command. |
|
37 | + * |
|
38 | + * @return mixed |
|
39 | + */ |
|
40 | + public function handle() |
|
41 | + { |
|
42 | + if($this->argument('name') == "all"){ |
|
43 | + $this->all(); |
|
44 | + } elseif($this->argument('name') == "city"){ |
|
45 | + RajaOngkir::cachingCity(); |
|
46 | + } elseif($this->argument('name') == "province"){ |
|
47 | + RajaOngkir::cachingProvince(); |
|
48 | + } elseif($this->argument('name') == "subdistrict"){ |
|
49 | + RajaOngkir::cachingSubDistrict(); |
|
50 | + } elseif($this->argument('name') == "clear"){ |
|
51 | + CacheCMD::clearCache(); |
|
52 | + } elseif($this->argument('name') == "refresh"){ |
|
53 | + CacheCMD::refresh(); |
|
54 | + } else{ |
|
55 | + $this->line('<fg=yellow>valid input is all, clear, refresh, city, province and subdistrict.'); |
|
56 | + } |
|
57 | + } |
|
58 | + private function all(){ |
|
59 | + $this->line("|_ _| / _| | ___ \ (_) | _ | | | (_) |
|
60 | 60 | | | _ __| |_ __ _ ______ | |_/ /__ _ _ __ _ | | | |_ __ __ _| | ___ _ __ |
61 | 61 | | || '__| _/ _` | |______| | // _` | |/ _` | | | | | '_ \ / _` | |/ / | '__| |
62 | 62 | _| || | | || (_| | | |\ \ (_| | | (_| | \ \_/ / | | | (_| | <| | | |
63 | 63 | \___/_| |_| \__,_| \_| \_\__,_| |\__,_| \___/|_| |_|\__, |_|\_\_|_| |
64 | 64 | _/ | __/ | |
65 | 65 | |__/ |___/ ".PHP_EOL); |
66 | - echo "---------------------".PHP_EOL; |
|
67 | - echo"Province Caching".PHP_EOL; |
|
68 | - echo"---------------------".PHP_EOL; |
|
69 | - RajaOngkir::cachingProvince(); |
|
70 | - echo PHP_EOL."---------------------".PHP_EOL; |
|
71 | - sleep(1);//Cooling Down |
|
72 | - echo"City Caching".PHP_EOL; |
|
73 | - echo "---------------------".PHP_EOL; |
|
74 | - RajaOngkir::cachingCity(); |
|
75 | - echo PHP_EOL."---------------------".PHP_EOL; |
|
76 | - sleep(1);//Cooling Down |
|
77 | - echo"Subdistrict Caching".PHP_EOL; |
|
78 | - echo "---------------------".PHP_EOL; |
|
79 | - RajaOngkir::cachingSubDistrict(); |
|
80 | - echo PHP_EOL."---------------------".PHP_EOL; |
|
81 | - } |
|
82 | - private function refresh(){ |
|
83 | - echo "---------------------".PHP_EOL; |
|
84 | - echo"Refresh Cache".PHP_EOL; |
|
85 | - echo"---------------------".PHP_EOL; |
|
86 | - CacheCMD::clearCache(); |
|
87 | - echo "---------------------".PHP_EOL; |
|
88 | - echo"Province Caching".PHP_EOL; |
|
89 | - echo"---------------------".PHP_EOL; |
|
90 | - RajaOngkir::cachingProvince(); |
|
91 | - echo PHP_EOL."---------------------".PHP_EOL; |
|
92 | - sleep(1);//Cooling Down |
|
93 | - echo"City Caching".PHP_EOL; |
|
94 | - echo "---------------------".PHP_EOL; |
|
95 | - RajaOngkir::cachingCity(); |
|
96 | - echo PHP_EOL."---------------------".PHP_EOL; |
|
97 | - sleep(1);//Cooling Down |
|
98 | - echo"Subdistrict Caching".PHP_EOL; |
|
99 | - echo "---------------------".PHP_EOL; |
|
100 | - RajaOngkir::cachingSubDistrict(); |
|
101 | - echo PHP_EOL."---------------------".PHP_EOL; |
|
102 | - } |
|
66 | + echo "---------------------".PHP_EOL; |
|
67 | + echo"Province Caching".PHP_EOL; |
|
68 | + echo"---------------------".PHP_EOL; |
|
69 | + RajaOngkir::cachingProvince(); |
|
70 | + echo PHP_EOL."---------------------".PHP_EOL; |
|
71 | + sleep(1);//Cooling Down |
|
72 | + echo"City Caching".PHP_EOL; |
|
73 | + echo "---------------------".PHP_EOL; |
|
74 | + RajaOngkir::cachingCity(); |
|
75 | + echo PHP_EOL."---------------------".PHP_EOL; |
|
76 | + sleep(1);//Cooling Down |
|
77 | + echo"Subdistrict Caching".PHP_EOL; |
|
78 | + echo "---------------------".PHP_EOL; |
|
79 | + RajaOngkir::cachingSubDistrict(); |
|
80 | + echo PHP_EOL."---------------------".PHP_EOL; |
|
81 | + } |
|
82 | + private function refresh(){ |
|
83 | + echo "---------------------".PHP_EOL; |
|
84 | + echo"Refresh Cache".PHP_EOL; |
|
85 | + echo"---------------------".PHP_EOL; |
|
86 | + CacheCMD::clearCache(); |
|
87 | + echo "---------------------".PHP_EOL; |
|
88 | + echo"Province Caching".PHP_EOL; |
|
89 | + echo"---------------------".PHP_EOL; |
|
90 | + RajaOngkir::cachingProvince(); |
|
91 | + echo PHP_EOL."---------------------".PHP_EOL; |
|
92 | + sleep(1);//Cooling Down |
|
93 | + echo"City Caching".PHP_EOL; |
|
94 | + echo "---------------------".PHP_EOL; |
|
95 | + RajaOngkir::cachingCity(); |
|
96 | + echo PHP_EOL."---------------------".PHP_EOL; |
|
97 | + sleep(1);//Cooling Down |
|
98 | + echo"Subdistrict Caching".PHP_EOL; |
|
99 | + echo "---------------------".PHP_EOL; |
|
100 | + RajaOngkir::cachingSubDistrict(); |
|
101 | + echo PHP_EOL."---------------------".PHP_EOL; |
|
102 | + } |
|
103 | 103 | } |
@@ -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(); |
@@ -6,32 +6,32 @@ |
||
6 | 6 | |
7 | 7 | class CreateSubdistrict extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function up() |
|
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(); |
|
24 | - $table->timestamps(); |
|
25 | - }); |
|
26 | - } |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function up() |
|
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(); |
|
24 | + $table->timestamps(); |
|
25 | + }); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Reverse the migrations. |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public function down() |
|
34 | - { |
|
35 | - Schema::dropIfExists('ro_subdistrict'); |
|
36 | - } |
|
28 | + /** |
|
29 | + * Reverse the migrations. |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public function down() |
|
34 | + { |
|
35 | + Schema::dropIfExists('ro_subdistrict'); |
|
36 | + } |
|
37 | 37 | } |
@@ -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 | } |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | - /* Config for PHP Native or non-Framework */ |
|
3 | + /* Config for PHP Native or non-Framework */ |
|
4 | 4 | |
5 | - $config = [ |
|
6 | - /* |
|
5 | + $config = [ |
|
6 | + /* |
|
7 | 7 | |-------------------------------------------------------------------------- |
8 | 8 | | End Point Api ( Server Configuration ) |
9 | 9 | |-------------------------------------------------------------------------- |
@@ -13,21 +13,21 @@ discard block |
||
13 | 13 | | Pro : http://pro.rajaongkir.com/api |
14 | 14 | | |
15 | 15 | */ |
16 | - 'account_type' => 'starter', |
|
17 | - /* |
|
16 | + 'account_type' => 'starter', |
|
17 | + /* |
|
18 | 18 | |-------------------------------------------------------------------------- |
19 | 19 | | API key |
20 | 20 | |-------------------------------------------------------------------------- |
21 | 21 | | You can get API key in www.rajaongkir.com |
22 | 22 | | |
23 | 23 | */ |
24 | - 'api_key' => 'your-api-key', |
|
25 | - /* |
|
24 | + 'api_key' => 'your-api-key', |
|
25 | + /* |
|
26 | 26 | |-------------------------------------------------------------------------- |
27 | 27 | | API Version (for account type basic and pro) |
28 | 28 | |-------------------------------------------------------------------------- |
29 | 29 | | You can get API key in www.rajaongkir.com |
30 | 30 | | |
31 | 31 | */ |
32 | - 'api_key' => 'v2', |
|
33 | - ]; |
|
32 | + 'api_key' => 'v2', |
|
33 | + ]; |
@@ -13,119 +13,119 @@ |
||
13 | 13 | |
14 | 14 | class ROCache |
15 | 15 | { |
16 | - private static $prov; |
|
17 | - private static $city; |
|
18 | - |
|
19 | - public static function cacheFile($name, $find = null) |
|
20 | - { |
|
21 | - $cache = Cache::get('ro-cache-'.$name); |
|
22 | - if ($find != null) { |
|
23 | - $cache = collect($cache)->where('province_id', $find['province_id']); |
|
24 | - } |
|
25 | - |
|
26 | - return $cache; |
|
27 | - } |
|
28 | - |
|
29 | - public static function clearCache() |
|
30 | - { |
|
31 | - self::$prov = config('irfa.rajaongkir.province_table'); |
|
32 | - self::$city = config('irfa.rajaongkir.city_table'); |
|
33 | - $cache_type = strtolower(config('irfa.rajaongkir.cache_type')); |
|
34 | - if ($cache_type == 'database') { |
|
35 | - if (Schema::hasTable(self::$city) and Schema::hasTable(self::$prov)) { |
|
36 | - echo 'Clearing Cache...'.PHP_EOL; |
|
37 | - self::clearTable(); |
|
38 | - echo 'Cache Cleared.'; |
|
39 | - } else { |
|
40 | - echo 'Failed. Cache table not found.'; |
|
41 | - |
|
42 | - return false; |
|
43 | - } |
|
44 | - } elseif ($cache_type == 'file') { |
|
45 | - echo 'Clearing Cache...'.PHP_EOL; |
|
46 | - self::clearFile(); |
|
47 | - echo 'Cache Cleared.'; |
|
48 | - } else { |
|
49 | - echo 'Failed. Cache type not support.'; |
|
50 | - |
|
51 | - return false; |
|
52 | - } |
|
53 | - self::$prov = null; |
|
54 | - self::$city = null; |
|
55 | - } |
|
56 | - |
|
57 | - private static function clearTable() |
|
58 | - { |
|
59 | - DB::table(self::$prov)->truncate(); |
|
60 | - DB::table(self::$city)->truncate(); |
|
61 | - } |
|
62 | - |
|
63 | - private static function clearFile() |
|
64 | - { |
|
65 | - Cache::forget('ro-cache-'.self::$city); |
|
66 | - Cache::forget('ro-cache-'.self::$prov); |
|
67 | - } |
|
68 | - |
|
69 | - public static function checkProv() |
|
70 | - { |
|
71 | - $table = config('irfa.rajaongkir.province_table'); |
|
72 | - if (Schema::hasTable($table)) { |
|
73 | - $count = DB::table($table)->count(); |
|
74 | - if ($count > 0) { |
|
75 | - return true; |
|
76 | - } else { |
|
77 | - return false; |
|
78 | - } |
|
79 | - } else { |
|
80 | - return false; |
|
81 | - } |
|
82 | - } |
|
83 | - |
|
84 | - public static function checkCity() |
|
85 | - { |
|
86 | - $table = config('irfa.rajaongkir.city_table'); |
|
87 | - if (Schema::hasTable($table)) { |
|
88 | - $count = DB::table($table)->count(); |
|
89 | - if ($count > 0) { |
|
90 | - return true; |
|
91 | - } else { |
|
92 | - return false; |
|
93 | - } |
|
94 | - } else { |
|
95 | - return false; |
|
96 | - } |
|
97 | - } |
|
98 | - |
|
99 | - public static function getProv($arr) |
|
100 | - { |
|
101 | - $db = DB::table(config('irfa.rajaongkir.province_table')); |
|
102 | - if (!empty($arr)) { |
|
103 | - $db->where($arr); |
|
104 | - } |
|
105 | - $ret = $db->orderBy('province', 'DESC')->get(); |
|
106 | - |
|
107 | - return $ret; |
|
108 | - } |
|
109 | - |
|
110 | - public static function getSubdistrict($arr) |
|
111 | - { |
|
112 | - $db = DB::table(config('irfa.rajaongkir.subdistrict_table')); |
|
113 | - if (!empty($arr)) { |
|
114 | - $db->where($arr); |
|
115 | - } |
|
116 | - $ret = $db->orderBy('subdistrict_name', 'DESC')->get(); |
|
117 | - |
|
118 | - return $ret; |
|
119 | - } |
|
120 | - |
|
121 | - public static function getCity($arr) |
|
122 | - { |
|
123 | - $db = DB::table(config('irfa.rajaongkir.city_table')); |
|
124 | - if (!empty($arr)) { |
|
125 | - $db->where($arr); |
|
126 | - } |
|
127 | - $ret = $db->orderBy('city_name', 'ASC')->get(); |
|
128 | - |
|
129 | - return $ret; |
|
130 | - } |
|
16 | + private static $prov; |
|
17 | + private static $city; |
|
18 | + |
|
19 | + public static function cacheFile($name, $find = null) |
|
20 | + { |
|
21 | + $cache = Cache::get('ro-cache-'.$name); |
|
22 | + if ($find != null) { |
|
23 | + $cache = collect($cache)->where('province_id', $find['province_id']); |
|
24 | + } |
|
25 | + |
|
26 | + return $cache; |
|
27 | + } |
|
28 | + |
|
29 | + public static function clearCache() |
|
30 | + { |
|
31 | + self::$prov = config('irfa.rajaongkir.province_table'); |
|
32 | + self::$city = config('irfa.rajaongkir.city_table'); |
|
33 | + $cache_type = strtolower(config('irfa.rajaongkir.cache_type')); |
|
34 | + if ($cache_type == 'database') { |
|
35 | + if (Schema::hasTable(self::$city) and Schema::hasTable(self::$prov)) { |
|
36 | + echo 'Clearing Cache...'.PHP_EOL; |
|
37 | + self::clearTable(); |
|
38 | + echo 'Cache Cleared.'; |
|
39 | + } else { |
|
40 | + echo 'Failed. Cache table not found.'; |
|
41 | + |
|
42 | + return false; |
|
43 | + } |
|
44 | + } elseif ($cache_type == 'file') { |
|
45 | + echo 'Clearing Cache...'.PHP_EOL; |
|
46 | + self::clearFile(); |
|
47 | + echo 'Cache Cleared.'; |
|
48 | + } else { |
|
49 | + echo 'Failed. Cache type not support.'; |
|
50 | + |
|
51 | + return false; |
|
52 | + } |
|
53 | + self::$prov = null; |
|
54 | + self::$city = null; |
|
55 | + } |
|
56 | + |
|
57 | + private static function clearTable() |
|
58 | + { |
|
59 | + DB::table(self::$prov)->truncate(); |
|
60 | + DB::table(self::$city)->truncate(); |
|
61 | + } |
|
62 | + |
|
63 | + private static function clearFile() |
|
64 | + { |
|
65 | + Cache::forget('ro-cache-'.self::$city); |
|
66 | + Cache::forget('ro-cache-'.self::$prov); |
|
67 | + } |
|
68 | + |
|
69 | + public static function checkProv() |
|
70 | + { |
|
71 | + $table = config('irfa.rajaongkir.province_table'); |
|
72 | + if (Schema::hasTable($table)) { |
|
73 | + $count = DB::table($table)->count(); |
|
74 | + if ($count > 0) { |
|
75 | + return true; |
|
76 | + } else { |
|
77 | + return false; |
|
78 | + } |
|
79 | + } else { |
|
80 | + return false; |
|
81 | + } |
|
82 | + } |
|
83 | + |
|
84 | + public static function checkCity() |
|
85 | + { |
|
86 | + $table = config('irfa.rajaongkir.city_table'); |
|
87 | + if (Schema::hasTable($table)) { |
|
88 | + $count = DB::table($table)->count(); |
|
89 | + if ($count > 0) { |
|
90 | + return true; |
|
91 | + } else { |
|
92 | + return false; |
|
93 | + } |
|
94 | + } else { |
|
95 | + return false; |
|
96 | + } |
|
97 | + } |
|
98 | + |
|
99 | + public static function getProv($arr) |
|
100 | + { |
|
101 | + $db = DB::table(config('irfa.rajaongkir.province_table')); |
|
102 | + if (!empty($arr)) { |
|
103 | + $db->where($arr); |
|
104 | + } |
|
105 | + $ret = $db->orderBy('province', 'DESC')->get(); |
|
106 | + |
|
107 | + return $ret; |
|
108 | + } |
|
109 | + |
|
110 | + public static function getSubdistrict($arr) |
|
111 | + { |
|
112 | + $db = DB::table(config('irfa.rajaongkir.subdistrict_table')); |
|
113 | + if (!empty($arr)) { |
|
114 | + $db->where($arr); |
|
115 | + } |
|
116 | + $ret = $db->orderBy('subdistrict_name', 'DESC')->get(); |
|
117 | + |
|
118 | + return $ret; |
|
119 | + } |
|
120 | + |
|
121 | + public static function getCity($arr) |
|
122 | + { |
|
123 | + $db = DB::table(config('irfa.rajaongkir.city_table')); |
|
124 | + if (!empty($arr)) { |
|
125 | + $db->where($arr); |
|
126 | + } |
|
127 | + $ret = $db->orderBy('city_name', 'ASC')->get(); |
|
128 | + |
|
129 | + return $ret; |
|
130 | + } |
|
131 | 131 | } |
@@ -6,39 +6,39 @@ |
||
6 | 6 | |
7 | 7 | class DBImport |
8 | 8 | { |
9 | - protected static $table_DB; |
|
9 | + protected static $table_DB; |
|
10 | 10 | |
11 | - protected static function import($table, $result, $type = 'prov') |
|
12 | - { |
|
13 | - self::$table_DB = $table; |
|
14 | - echo 'Creating cache... '.PHP_EOL; |
|
15 | - self::extractor($result, $type); |
|
16 | - } |
|
11 | + protected static function import($table, $result, $type = 'prov') |
|
12 | + { |
|
13 | + self::$table_DB = $table; |
|
14 | + echo 'Creating cache... '.PHP_EOL; |
|
15 | + self::extractor($result, $type); |
|
16 | + } |
|
17 | 17 | |
18 | - private static function extractor($result, $type) |
|
19 | - { |
|
20 | - try { |
|
21 | - foreach ($result as $r) { |
|
22 | - if ($type == 'prov') { |
|
23 | - $fill = ['province_id' => $r->province_id, 'province' => $r->province]; |
|
24 | - $where = ['province_id' => $r->province_id]; |
|
25 | - } elseif ($type == 'city') { |
|
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 | - $where = ['city_id' => $r->city_id]; |
|
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]; |
|
30 | - $where = ['subdistrict_id' => $r->subdistrict_id]; |
|
31 | - } |
|
32 | - if (DB::table(self::$table_DB)->where($where)->count() == 0) { |
|
33 | - DB::table(self::$table_DB)->insert($fill); |
|
34 | - } else { |
|
35 | - DB::table(self::$table_DB)->where($where)->update($fill); |
|
36 | - } |
|
37 | - } |
|
38 | - $count = DB::table(self::$table_DB)->count(); |
|
39 | - echo 'Cache has been created, '.$count.' row(s) affected.'; |
|
40 | - } catch (\Exception $e) { |
|
41 | - echo "\033[91mCan't creating cache. Error\033[0m : ".$e; |
|
42 | - } |
|
43 | - } |
|
18 | + private static function extractor($result, $type) |
|
19 | + { |
|
20 | + try { |
|
21 | + foreach ($result as $r) { |
|
22 | + if ($type == 'prov') { |
|
23 | + $fill = ['province_id' => $r->province_id, 'province' => $r->province]; |
|
24 | + $where = ['province_id' => $r->province_id]; |
|
25 | + } elseif ($type == 'city') { |
|
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 | + $where = ['city_id' => $r->city_id]; |
|
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]; |
|
30 | + $where = ['subdistrict_id' => $r->subdistrict_id]; |
|
31 | + } |
|
32 | + if (DB::table(self::$table_DB)->where($where)->count() == 0) { |
|
33 | + DB::table(self::$table_DB)->insert($fill); |
|
34 | + } else { |
|
35 | + DB::table(self::$table_DB)->where($where)->update($fill); |
|
36 | + } |
|
37 | + } |
|
38 | + $count = DB::table(self::$table_DB)->count(); |
|
39 | + echo 'Cache has been created, '.$count.' row(s) affected.'; |
|
40 | + } catch (\Exception $e) { |
|
41 | + echo "\033[91mCan't creating cache. Error\033[0m : ".$e; |
|
42 | + } |
|
43 | + } |
|
44 | 44 | } |
@@ -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) { |
@@ -6,61 +6,61 @@ |
||
6 | 6 | |
7 | 7 | class CacheCurl extends DBImport |
8 | 8 | { |
9 | - private static $bucket; |
|
10 | - private static $table; |
|
11 | - private static $type; |
|
9 | + private static $bucket; |
|
10 | + private static $table; |
|
11 | + private static $type; |
|
12 | 12 | |
13 | - protected static function caching($results) |
|
14 | - { |
|
15 | - self::$bucket = $results; |
|
13 | + protected static function caching($results) |
|
14 | + { |
|
15 | + self::$bucket = $results; |
|
16 | 16 | |
17 | - return new static(); |
|
18 | - } |
|
17 | + return new static(); |
|
18 | + } |
|
19 | 19 | |
20 | - private static function _import() |
|
21 | - { |
|
22 | - $cache_type = strtolower(config('irfa.rajaongkir.cache_type')); |
|
23 | - if ($cache_type == 'file') { |
|
24 | - Cache::store('file')->put('ro-cache-'.self::$table, self::$bucket); |
|
25 | - echo'Cache has been created. '.self::formatBytes(strlen(serialize(Cache::get('ro-cache-'.self::$table)))); |
|
26 | - } elseif ($cache_type == 'database') { |
|
27 | - self::import(self::$table, self::$bucket, self::$type); |
|
28 | - } elseif ($cache_type == null) { |
|
29 | - echo'Please set cache type.'; |
|
30 | - } else { |
|
31 | - echo'Cache type is not supported.'; |
|
32 | - } |
|
33 | - self::$bucket = null; |
|
34 | - self::$type = null; |
|
35 | - self::$table = null; |
|
36 | - } |
|
20 | + private static function _import() |
|
21 | + { |
|
22 | + $cache_type = strtolower(config('irfa.rajaongkir.cache_type')); |
|
23 | + if ($cache_type == 'file') { |
|
24 | + Cache::store('file')->put('ro-cache-'.self::$table, self::$bucket); |
|
25 | + echo'Cache has been created. '.self::formatBytes(strlen(serialize(Cache::get('ro-cache-'.self::$table)))); |
|
26 | + } elseif ($cache_type == 'database') { |
|
27 | + self::import(self::$table, self::$bucket, self::$type); |
|
28 | + } elseif ($cache_type == null) { |
|
29 | + echo'Please set cache type.'; |
|
30 | + } else { |
|
31 | + echo'Cache type is not supported.'; |
|
32 | + } |
|
33 | + self::$bucket = null; |
|
34 | + self::$type = null; |
|
35 | + self::$table = null; |
|
36 | + } |
|
37 | 37 | |
38 | - protected static function province() |
|
39 | - { |
|
40 | - self::$table = config('irfa.rajaongkir.province_table'); |
|
41 | - self::$type = 'prov'; |
|
42 | - self::_import(); |
|
43 | - } |
|
38 | + protected static function province() |
|
39 | + { |
|
40 | + self::$table = config('irfa.rajaongkir.province_table'); |
|
41 | + self::$type = 'prov'; |
|
42 | + self::_import(); |
|
43 | + } |
|
44 | 44 | |
45 | - protected static function city() |
|
46 | - { |
|
47 | - self::$table = config('irfa.rajaongkir.city_table'); |
|
48 | - self::$type = 'city'; |
|
49 | - self::_import(); |
|
50 | - } |
|
45 | + protected static function city() |
|
46 | + { |
|
47 | + self::$table = config('irfa.rajaongkir.city_table'); |
|
48 | + self::$type = 'city'; |
|
49 | + self::_import(); |
|
50 | + } |
|
51 | 51 | |
52 | - protected static function subdistrict() |
|
53 | - { |
|
54 | - self::$table = config('irfa.rajaongkir.subdistrict_table'); |
|
55 | - self::$type = 'subdistrict'; |
|
56 | - self::_import(); |
|
57 | - } |
|
52 | + protected static function subdistrict() |
|
53 | + { |
|
54 | + self::$table = config('irfa.rajaongkir.subdistrict_table'); |
|
55 | + self::$type = 'subdistrict'; |
|
56 | + self::_import(); |
|
57 | + } |
|
58 | 58 | |
59 | - private static function formatBytes($size, $precision = 2) |
|
60 | - { |
|
61 | - $base = log($size, 1024); |
|
62 | - $suffixes = ['B', 'KB', 'MB', 'GB', 'TB']; |
|
59 | + private static function formatBytes($size, $precision = 2) |
|
60 | + { |
|
61 | + $base = log($size, 1024); |
|
62 | + $suffixes = ['B', 'KB', 'MB', 'GB', 'TB']; |
|
63 | 63 | |
64 | - return round(pow(1024, $base - floor($base)), $precision).' '.$suffixes[floor($base)]; |
|
65 | - } |
|
64 | + return round(pow(1024, $base - floor($base)), $precision).' '.$suffixes[floor($base)]; |
|
65 | + } |
|
66 | 66 | } |
@@ -6,38 +6,38 @@ |
||
6 | 6 | |
7 | 7 | class RajaOngkirServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * Register services. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
9 | + /** |
|
10 | + * Register services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | 14 | |
15 | - protected $commands = [ |
|
16 | - 'Irfa\RajaOngkir\Console\Commands\ROCache', |
|
17 | - 'Irfa\RajaOngkir\Console\Commands\ROInfoPackage', |
|
18 | - ]; |
|
19 | - |
|
20 | - public function register() |
|
21 | - { |
|
22 | - $this->commands($this->commands); |
|
23 | - |
|
24 | - } |
|
25 | - |
|
26 | - /** |
|
27 | - * Bootstrap services. |
|
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function boot() |
|
32 | - { |
|
33 | - $this->publishes([ |
|
34 | - __DIR__.'/../resources/config/irfa/rajaongkir.php' => config_path('irfa/rajaongkir.php'), ], 'raja-ongkir'); |
|
35 | - |
|
36 | - $this->publishes([ |
|
37 | - __DIR__.'/../database/migrations/' => database_path('migrations'), |
|
38 | - ], 'raja-ongkir'); |
|
39 | - |
|
40 | - $this->publishes([__DIR__.'/../database/migrations/' => database_path('migrations'), |
|
41 | - ], 'raja-ongkir'); |
|
42 | - } |
|
15 | + protected $commands = [ |
|
16 | + 'Irfa\RajaOngkir\Console\Commands\ROCache', |
|
17 | + 'Irfa\RajaOngkir\Console\Commands\ROInfoPackage', |
|
18 | + ]; |
|
19 | + |
|
20 | + public function register() |
|
21 | + { |
|
22 | + $this->commands($this->commands); |
|
23 | + |
|
24 | + } |
|
25 | + |
|
26 | + /** |
|
27 | + * Bootstrap services. |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function boot() |
|
32 | + { |
|
33 | + $this->publishes([ |
|
34 | + __DIR__.'/../resources/config/irfa/rajaongkir.php' => config_path('irfa/rajaongkir.php'), ], 'raja-ongkir'); |
|
35 | + |
|
36 | + $this->publishes([ |
|
37 | + __DIR__.'/../database/migrations/' => database_path('migrations'), |
|
38 | + ], 'raja-ongkir'); |
|
39 | + |
|
40 | + $this->publishes([__DIR__.'/../database/migrations/' => database_path('migrations'), |
|
41 | + ], 'raja-ongkir'); |
|
42 | + } |
|
43 | 43 | } |
@@ -7,89 +7,89 @@ |
||
7 | 7 | |
8 | 8 | class ROCache extends Command |
9 | 9 | { |
10 | - /** |
|
11 | - * The name and signature of the console command. |
|
12 | - * |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $signature = 'raja-ongkir:cache {name}'; |
|
10 | + /** |
|
11 | + * The name and signature of the console command. |
|
12 | + * |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $signature = 'raja-ongkir:cache {name}'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * The console command description. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected $description = 'Create cache RajaOngkir'; |
|
17 | + /** |
|
18 | + * The console command description. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected $description = 'Create cache RajaOngkir'; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Create a new command instance. |
|
26 | - * |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - public function __construct() |
|
30 | - { |
|
31 | - parent::__construct(); |
|
32 | - } |
|
24 | + /** |
|
25 | + * Create a new command instance. |
|
26 | + * |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + public function __construct() |
|
30 | + { |
|
31 | + parent::__construct(); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Execute the console command. |
|
36 | - * |
|
37 | - * @return mixed |
|
38 | - */ |
|
39 | - public function handle() |
|
40 | - { |
|
41 | - if($this->argument('name') == "all"){ |
|
42 | - $this->all(); |
|
43 | - } elseif($this->argument('name') == "city"){ |
|
44 | - RajaOngkir::cachingCity(); |
|
45 | - } elseif($this->argument('name') == "province"){ |
|
46 | - RajaOngkir::cachingProvince(); |
|
47 | - } elseif($this->argument('name') == "subdistrict"){ |
|
48 | - RajaOngkir::cachingSubDistrict(); |
|
49 | - } elseif($this->argument('name') == "clear"){ |
|
50 | - ROCache::clearCache(); |
|
51 | - } elseif($this->argument('name') == "refresh"){ |
|
52 | - ROCache::refresh(); |
|
53 | - } else{ |
|
54 | - $this->line('<fg=yellow>Valid input is all, clear, refresh, city, province and subdistrict.'); |
|
55 | - } |
|
56 | - } |
|
57 | - private function all(){ |
|
58 | - echo "---------------------".PHP_EOL; |
|
59 | - echo"Province Caching".PHP_EOL; |
|
60 | - echo"---------------------".PHP_EOL; |
|
61 | - RajaOngkir::cachingProvince(); |
|
62 | - echo PHP_EOL."---------------------".PHP_EOL; |
|
63 | - sleep(1);//Cooling Down |
|
64 | - echo"City Caching".PHP_EOL; |
|
65 | - echo "---------------------".PHP_EOL; |
|
66 | - RajaOngkir::cachingCity(); |
|
67 | - echo PHP_EOL."---------------------".PHP_EOL; |
|
68 | - sleep(1);//Cooling Down |
|
69 | - echo"Subdistrict Caching".PHP_EOL; |
|
70 | - echo "---------------------".PHP_EOL; |
|
71 | - RajaOngkir::cachingSubDistrict(); |
|
72 | - echo PHP_EOL."---------------------".PHP_EOL; |
|
73 | - } |
|
74 | - private function refresh(){ |
|
75 | - echo "---------------------".PHP_EOL; |
|
76 | - echo"Refresh Cache".PHP_EOL; |
|
77 | - echo"---------------------".PHP_EOL; |
|
78 | - ROCache::clearCache(); |
|
79 | - echo "---------------------".PHP_EOL; |
|
80 | - echo"Province Caching".PHP_EOL; |
|
81 | - echo"---------------------".PHP_EOL; |
|
82 | - RajaOngkir::cachingProvince(); |
|
83 | - echo PHP_EOL."---------------------".PHP_EOL; |
|
84 | - sleep(1);//Cooling Down |
|
85 | - echo"City Caching".PHP_EOL; |
|
86 | - echo "---------------------".PHP_EOL; |
|
87 | - RajaOngkir::cachingCity(); |
|
88 | - echo PHP_EOL."---------------------".PHP_EOL; |
|
89 | - sleep(1);//Cooling Down |
|
90 | - echo"Subdistrict Caching".PHP_EOL; |
|
91 | - echo "---------------------".PHP_EOL; |
|
92 | - RajaOngkir::cachingSubDistrict(); |
|
93 | - echo PHP_EOL."---------------------".PHP_EOL; |
|
94 | - } |
|
34 | + /** |
|
35 | + * Execute the console command. |
|
36 | + * |
|
37 | + * @return mixed |
|
38 | + */ |
|
39 | + public function handle() |
|
40 | + { |
|
41 | + if($this->argument('name') == "all"){ |
|
42 | + $this->all(); |
|
43 | + } elseif($this->argument('name') == "city"){ |
|
44 | + RajaOngkir::cachingCity(); |
|
45 | + } elseif($this->argument('name') == "province"){ |
|
46 | + RajaOngkir::cachingProvince(); |
|
47 | + } elseif($this->argument('name') == "subdistrict"){ |
|
48 | + RajaOngkir::cachingSubDistrict(); |
|
49 | + } elseif($this->argument('name') == "clear"){ |
|
50 | + ROCache::clearCache(); |
|
51 | + } elseif($this->argument('name') == "refresh"){ |
|
52 | + ROCache::refresh(); |
|
53 | + } else{ |
|
54 | + $this->line('<fg=yellow>Valid input is all, clear, refresh, city, province and subdistrict.'); |
|
55 | + } |
|
56 | + } |
|
57 | + private function all(){ |
|
58 | + echo "---------------------".PHP_EOL; |
|
59 | + echo"Province Caching".PHP_EOL; |
|
60 | + echo"---------------------".PHP_EOL; |
|
61 | + RajaOngkir::cachingProvince(); |
|
62 | + echo PHP_EOL."---------------------".PHP_EOL; |
|
63 | + sleep(1);//Cooling Down |
|
64 | + echo"City Caching".PHP_EOL; |
|
65 | + echo "---------------------".PHP_EOL; |
|
66 | + RajaOngkir::cachingCity(); |
|
67 | + echo PHP_EOL."---------------------".PHP_EOL; |
|
68 | + sleep(1);//Cooling Down |
|
69 | + echo"Subdistrict Caching".PHP_EOL; |
|
70 | + echo "---------------------".PHP_EOL; |
|
71 | + RajaOngkir::cachingSubDistrict(); |
|
72 | + echo PHP_EOL."---------------------".PHP_EOL; |
|
73 | + } |
|
74 | + private function refresh(){ |
|
75 | + echo "---------------------".PHP_EOL; |
|
76 | + echo"Refresh Cache".PHP_EOL; |
|
77 | + echo"---------------------".PHP_EOL; |
|
78 | + ROCache::clearCache(); |
|
79 | + echo "---------------------".PHP_EOL; |
|
80 | + echo"Province Caching".PHP_EOL; |
|
81 | + echo"---------------------".PHP_EOL; |
|
82 | + RajaOngkir::cachingProvince(); |
|
83 | + echo PHP_EOL."---------------------".PHP_EOL; |
|
84 | + sleep(1);//Cooling Down |
|
85 | + echo"City Caching".PHP_EOL; |
|
86 | + echo "---------------------".PHP_EOL; |
|
87 | + RajaOngkir::cachingCity(); |
|
88 | + echo PHP_EOL."---------------------".PHP_EOL; |
|
89 | + sleep(1);//Cooling Down |
|
90 | + echo"Subdistrict Caching".PHP_EOL; |
|
91 | + echo "---------------------".PHP_EOL; |
|
92 | + RajaOngkir::cachingSubDistrict(); |
|
93 | + echo PHP_EOL."---------------------".PHP_EOL; |
|
94 | + } |
|
95 | 95 | } |
@@ -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(); |
@@ -7,60 +7,60 @@ discard block |
||
7 | 7 | |
8 | 8 | class ROInfoPackage extends Command |
9 | 9 | { |
10 | - /** |
|
11 | - * The name and signature of the console command. |
|
12 | - * |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $signature = 'raja-ongkir {cmd}'; |
|
10 | + /** |
|
11 | + * The name and signature of the console command. |
|
12 | + * |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $signature = 'raja-ongkir {cmd}'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * The console command description. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected $description = 'Option'; |
|
17 | + /** |
|
18 | + * The console command description. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected $description = 'Option'; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Create a new command instance. |
|
26 | - * |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - public function __construct() |
|
30 | - { |
|
31 | - parent::__construct(); |
|
32 | - } |
|
24 | + /** |
|
25 | + * Create a new command instance. |
|
26 | + * |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + public function __construct() |
|
30 | + { |
|
31 | + parent::__construct(); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Execute the console command. |
|
36 | - * |
|
37 | - * @return mixed |
|
38 | - */ |
|
39 | - public function handle() |
|
40 | - { |
|
41 | - if($this->argument('cmd') == "version" || $this->argument('cmd') == "v" ){ |
|
42 | - $this->informasi(); |
|
43 | - } elseif($this->argument('cmd') == "key"){ |
|
44 | - $this->line('Api Key: '.config('irfa.rajaongkir.api_key')); |
|
45 | - } elseif($this->argument('cmd') == "type"){ |
|
46 | - $this->line('Account Type: '.config('irfa.rajaongkir.account_type')); |
|
47 | - } elseif($this->argument('cmd') == "info"){ |
|
48 | - $this->informasi(); |
|
49 | - $this->line('-------------------------------------------------------------------------------'); |
|
50 | - $this->line('Account Type: '.config('irfa.rajaongkir.account_type')); |
|
51 | - $this->line('Api Key: '.config('irfa.rajaongkir.api_key')); |
|
52 | - $this->line('Api Version: '.config('irfa.rajaongkir.api_version')); |
|
53 | - $this->line('Province Table: '.config('irfa.rajaongkir.province_table')); |
|
54 | - $this->line('City Table: '.config('irfa.rajaongkir.city_table')); |
|
55 | - $this->line('Subdistrict Table: '.config('irfa.rajaongkir.subdistrict_table')); |
|
56 | - $this->line('Cache Type: '.config('irfa.rajaongkir.cache_type')); |
|
57 | - } else{ |
|
58 | - $this->line('<fg=yellow>valid input is version, key, type, info,and v.'); |
|
59 | - } |
|
60 | - } |
|
34 | + /** |
|
35 | + * Execute the console command. |
|
36 | + * |
|
37 | + * @return mixed |
|
38 | + */ |
|
39 | + public function handle() |
|
40 | + { |
|
41 | + if($this->argument('cmd') == "version" || $this->argument('cmd') == "v" ){ |
|
42 | + $this->informasi(); |
|
43 | + } elseif($this->argument('cmd') == "key"){ |
|
44 | + $this->line('Api Key: '.config('irfa.rajaongkir.api_key')); |
|
45 | + } elseif($this->argument('cmd') == "type"){ |
|
46 | + $this->line('Account Type: '.config('irfa.rajaongkir.account_type')); |
|
47 | + } elseif($this->argument('cmd') == "info"){ |
|
48 | + $this->informasi(); |
|
49 | + $this->line('-------------------------------------------------------------------------------'); |
|
50 | + $this->line('Account Type: '.config('irfa.rajaongkir.account_type')); |
|
51 | + $this->line('Api Key: '.config('irfa.rajaongkir.api_key')); |
|
52 | + $this->line('Api Version: '.config('irfa.rajaongkir.api_version')); |
|
53 | + $this->line('Province Table: '.config('irfa.rajaongkir.province_table')); |
|
54 | + $this->line('City Table: '.config('irfa.rajaongkir.city_table')); |
|
55 | + $this->line('Subdistrict Table: '.config('irfa.rajaongkir.subdistrict_table')); |
|
56 | + $this->line('Cache Type: '.config('irfa.rajaongkir.cache_type')); |
|
57 | + } else{ |
|
58 | + $this->line('<fg=yellow>valid input is version, key, type, info,and v.'); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - private function informasi(){ |
|
63 | - $this->line(" |_ _| / _| | __ \ (_) / __ \ | | (_) |
|
62 | + private function informasi(){ |
|
63 | + $this->line(" |_ _| / _| | __ \ (_) / __ \ | | (_) |
|
64 | 64 | | | _ __| |_ __ _ ______ | |__) |__ _ _ __ _ | | | |_ __ __ _| | ___ _ __ |
65 | 65 | | | | '__| _/ _` | |______| | _ // _` | |/ _` | | | | | '_ \ / _` | |/ / | '__| |
66 | 66 | _| |_| | | || (_| | | | \ \ (_| | | (_| | | |__| | | | | (_| | <| | | |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | _/ | __/ | |
69 | 69 | |__/ |___/ ".PHP_EOL); |
70 | 70 | |
71 | - $this->line('-------------------------------------------------------------------------------'); |
|
72 | - $this->line('Raja Ongkir'); |
|
73 | - $this->line('Version 1.6.0 (2020)'); |
|
74 | - $this->line('https://github.com/irfaardy/raja-ongkir'); |
|
75 | - } |
|
71 | + $this->line('-------------------------------------------------------------------------------'); |
|
72 | + $this->line('Raja Ongkir'); |
|
73 | + $this->line('Version 1.6.0 (2020)'); |
|
74 | + $this->line('https://github.com/irfaardy/raja-ongkir'); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | } |
@@ -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 | | | | '__| _/ _` | |______| | _ // _` | |/ _` | | | | | '_ \ / _` | |/ / | '__| |
@@ -44,7 +44,7 @@ |
||
44 | 44 | $this->line('Api Key: '.config('irfa.rajaongkir.api_key')); |
45 | 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')); |