@@ -8,13 +8,13 @@  | 
                                                    ||
| 8 | 8 | |
| 9 | 9 | class Ongkir extends Facade  | 
                                                        
| 10 | 10 |  { | 
                                                        
| 11 | - /**  | 
                                                        |
| 12 | - * Get the registered name of the component.  | 
                                                        |
| 13 | - *  | 
                                                        |
| 14 | - * @return string  | 
                                                        |
| 15 | - */  | 
                                                        |
| 16 | - protected static function getFacadeAccessor()  | 
                                                        |
| 17 | -    { | 
                                                        |
| 18 | - return \Irfa\RajaOngkir\Ongkir\Ongkir::class;  | 
                                                        |
| 19 | - }  | 
                                                        |
| 11 | + /**  | 
                                                        |
| 12 | + * Get the registered name of the component.  | 
                                                        |
| 13 | + *  | 
                                                        |
| 14 | + * @return string  | 
                                                        |
| 15 | + */  | 
                                                        |
| 16 | + protected static function getFacadeAccessor()  | 
                                                        |
| 17 | +	{ | 
                                                        |
| 18 | + return \Irfa\RajaOngkir\Ongkir\Ongkir::class;  | 
                                                        |
| 19 | + }  | 
                                                        |
| 20 | 20 | }  | 
                                                        
@@ -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();  | 
                                                        
@@ -6,27 +6,27 @@  | 
                                                    ||
| 6 | 6 | |
| 7 | 7 | class CreateProvince extends Migration  | 
                                                        
| 8 | 8 |  { | 
                                                        
| 9 | - /**  | 
                                                        |
| 10 | - * Run the migrations.  | 
                                                        |
| 11 | - *  | 
                                                        |
| 12 | - * @return void  | 
                                                        |
| 13 | - */  | 
                                                        |
| 14 | - public function up()  | 
                                                        |
| 15 | -    { | 
                                                        |
| 16 | -        Schema::create('ro_province', function (Blueprint $table) { | 
                                                        |
| 17 | -            $table->string('province_id', 20)->primary(); | 
                                                        |
| 18 | -            $table->string('province', 255)->nullable(); | 
                                                        |
| 19 | - $table->timestamps();  | 
                                                        |
| 20 | - });  | 
                                                        |
| 21 | - }  | 
                                                        |
| 9 | + /**  | 
                                                        |
| 10 | + * Run the migrations.  | 
                                                        |
| 11 | + *  | 
                                                        |
| 12 | + * @return void  | 
                                                        |
| 13 | + */  | 
                                                        |
| 14 | + public function up()  | 
                                                        |
| 15 | +	{ | 
                                                        |
| 16 | +		Schema::create('ro_province', function (Blueprint $table) { | 
                                                        |
| 17 | +			$table->string('province_id', 20)->primary(); | 
                                                        |
| 18 | +			$table->string('province', 255)->nullable(); | 
                                                        |
| 19 | + $table->timestamps();  | 
                                                        |
| 20 | + });  | 
                                                        |
| 21 | + }  | 
                                                        |
| 22 | 22 | |
| 23 | - /**  | 
                                                        |
| 24 | - * Reverse the migrations.  | 
                                                        |
| 25 | - *  | 
                                                        |
| 26 | - * @return void  | 
                                                        |
| 27 | - */  | 
                                                        |
| 28 | - public function down()  | 
                                                        |
| 29 | -    { | 
                                                        |
| 30 | -        Schema::dropIfExists('ro_province'); | 
                                                        |
| 31 | - }  | 
                                                        |
| 23 | + /**  | 
                                                        |
| 24 | + * Reverse the migrations.  | 
                                                        |
| 25 | + *  | 
                                                        |
| 26 | + * @return void  | 
                                                        |
| 27 | + */  | 
                                                        |
| 28 | + public function down()  | 
                                                        |
| 29 | +	{ | 
                                                        |
| 30 | +		Schema::dropIfExists('ro_province'); | 
                                                        |
| 31 | + }  | 
                                                        |
| 32 | 32 | }  | 
                                                        
@@ -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(); | 
                                                        
@@ -6,31 +6,31 @@  | 
                                                    ||
| 6 | 6 | |
| 7 | 7 | class CreateCity extends Migration  | 
                                                        
| 8 | 8 |  { | 
                                                        
| 9 | - /**  | 
                                                        |
| 10 | - * Run the migrations.  | 
                                                        |
| 11 | - *  | 
                                                        |
| 12 | - * @return void  | 
                                                        |
| 13 | - */  | 
                                                        |
| 14 | - public function up()  | 
                                                        |
| 15 | -    { | 
                                                        |
| 16 | -        Schema::create('ro_city', function (Blueprint $table) { | 
                                                        |
| 17 | -            $table->string('city_id', 20)->primary(); | 
                                                        |
| 18 | -            $table->string('province_id', 20); | 
                                                        |
| 19 | -            $table->string('province', 120)->nullable(); | 
                                                        |
| 20 | -            $table->string('type', 60)->nullable(); | 
                                                        |
| 21 | -            $table->string('city_name', 128)->nullable(); | 
                                                        |
| 22 | -            $table->string('postal_code', 15)->nullable(); | 
                                                        |
| 23 | - $table->timestamps();  | 
                                                        |
| 24 | - });  | 
                                                        |
| 25 | - }  | 
                                                        |
| 9 | + /**  | 
                                                        |
| 10 | + * Run the migrations.  | 
                                                        |
| 11 | + *  | 
                                                        |
| 12 | + * @return void  | 
                                                        |
| 13 | + */  | 
                                                        |
| 14 | + public function up()  | 
                                                        |
| 15 | +	{ | 
                                                        |
| 16 | +		Schema::create('ro_city', function (Blueprint $table) { | 
                                                        |
| 17 | +			$table->string('city_id', 20)->primary(); | 
                                                        |
| 18 | +			$table->string('province_id', 20); | 
                                                        |
| 19 | +			$table->string('province', 120)->nullable(); | 
                                                        |
| 20 | +			$table->string('type', 60)->nullable(); | 
                                                        |
| 21 | +			$table->string('city_name', 128)->nullable(); | 
                                                        |
| 22 | +			$table->string('postal_code', 15)->nullable(); | 
                                                        |
| 23 | + $table->timestamps();  | 
                                                        |
| 24 | + });  | 
                                                        |
| 25 | + }  | 
                                                        |
| 26 | 26 | |
| 27 | - /**  | 
                                                        |
| 28 | - * Reverse the migrations.  | 
                                                        |
| 29 | - *  | 
                                                        |
| 30 | - * @return void  | 
                                                        |
| 31 | - */  | 
                                                        |
| 32 | - public function down()  | 
                                                        |
| 33 | -    { | 
                                                        |
| 34 | -        Schema::dropIfExists('ro_city'); | 
                                                        |
| 35 | - }  | 
                                                        |
| 27 | + /**  | 
                                                        |
| 28 | + * Reverse the migrations.  | 
                                                        |
| 29 | + *  | 
                                                        |
| 30 | + * @return void  | 
                                                        |
| 31 | + */  | 
                                                        |
| 32 | + public function down()  | 
                                                        |
| 33 | +	{ | 
                                                        |
| 34 | +		Schema::dropIfExists('ro_city'); | 
                                                        |
| 35 | + }  | 
                                                        |
| 36 | 36 | }  | 
                                                        
@@ -1,5 +1,5 @@  | 
                                                    ||
| 1 | 1 | <?php  | 
                                                        
| 2 | 2 | |
| 3 | 3 |  Route::get('raja-ongkir', function () { | 
                                                        
| 4 | - dd(RajaOngkir::getProvince());  | 
                                                        |
| 4 | + dd(RajaOngkir::getProvince());  | 
                                                        |
| 5 | 5 | });  | 
                                                        
@@ -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 | });  | 
                                                        
@@ -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) { |