@@ -7,37 +7,37 @@ |
||
7 | 7 | |
8 | 8 | class ROClearCache extends Command |
9 | 9 | { |
10 | - /** |
|
11 | - * The name and signature of the console command. |
|
12 | - * |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $signature = 'raja-ongkir:clear'; |
|
10 | + /** |
|
11 | + * The name and signature of the console command. |
|
12 | + * |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $signature = 'raja-ongkir:clear'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * The console command description. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected $description = 'Clearing cache province and city.'; |
|
17 | + /** |
|
18 | + * The console command description. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected $description = 'Clearing cache province and city.'; |
|
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 | - ROCache::clearCache(); |
|
42 | - } |
|
34 | + /** |
|
35 | + * Execute the console command. |
|
36 | + * |
|
37 | + * @return mixed |
|
38 | + */ |
|
39 | + public function handle() |
|
40 | + { |
|
41 | + ROCache::clearCache(); |
|
42 | + } |
|
43 | 43 | } |
@@ -7,37 +7,37 @@ |
||
7 | 7 | |
8 | 8 | class ROProvince extends Command |
9 | 9 | { |
10 | - /** |
|
11 | - * The name and signature of the console command. |
|
12 | - * |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $signature = 'raja-ongkir:prov-cache'; |
|
10 | + /** |
|
11 | + * The name and signature of the console command. |
|
12 | + * |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $signature = 'raja-ongkir:prov-cache'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * The console command description. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected $description = 'Create province list cache for faster loading province list'; |
|
17 | + /** |
|
18 | + * The console command description. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected $description = 'Create province list cache for faster loading province list'; |
|
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 | - RajaOngkir::cachingProvince(); |
|
42 | - } |
|
34 | + /** |
|
35 | + * Execute the console command. |
|
36 | + * |
|
37 | + * @return mixed |
|
38 | + */ |
|
39 | + public function handle() |
|
40 | + { |
|
41 | + RajaOngkir::cachingProvince(); |
|
42 | + } |
|
43 | 43 | } |
@@ -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 | } |
@@ -6,36 +6,36 @@ |
||
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 | - } |
|
29 | - if (DB::table(self::$table_DB)->where($where)->count() == 0) { |
|
30 | - DB::table(self::$table_DB)->insert($fill); |
|
31 | - } else { |
|
32 | - DB::table(self::$table_DB)->where($where)->update($fill); |
|
33 | - } |
|
34 | - } |
|
35 | - $count = DB::table(self::$table_DB)->count(); |
|
36 | - echo 'Cache has been created, '.$count.' row(s) affected.'; |
|
37 | - } catch (\Exception $e) { |
|
38 | - echo "\033[91mCan't creating cache. Error\033[0m : ".$e; |
|
39 | - } |
|
40 | - } |
|
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 | + } |
|
29 | + if (DB::table(self::$table_DB)->where($where)->count() == 0) { |
|
30 | + DB::table(self::$table_DB)->insert($fill); |
|
31 | + } else { |
|
32 | + DB::table(self::$table_DB)->where($where)->update($fill); |
|
33 | + } |
|
34 | + } |
|
35 | + $count = DB::table(self::$table_DB)->count(); |
|
36 | + echo 'Cache has been created, '.$count.' row(s) affected.'; |
|
37 | + } catch (\Exception $e) { |
|
38 | + echo "\033[91mCan't creating cache. Error\033[0m : ".$e; |
|
39 | + } |
|
40 | + } |
|
41 | 41 | } |
@@ -6,54 +6,54 @@ |
||
6 | 6 | |
7 | 7 | class CacheCurl extends DBImport |
8 | 8 | { |
9 | - private static $bucket; |
|
10 | - private static $table; |
|
11 | - private static $type; |
|
12 | - |
|
13 | - protected static function caching($results) |
|
14 | - { |
|
15 | - self::$bucket = $results; |
|
16 | - |
|
17 | - return new static(); |
|
18 | - } |
|
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 | - } |
|
37 | - |
|
38 | - protected static function province() |
|
39 | - { |
|
40 | - self::$table = config('irfa.rajaongkir.province_table'); |
|
41 | - self::$type = 'prov'; |
|
42 | - self::_import(); |
|
43 | - } |
|
44 | - |
|
45 | - protected static function city() |
|
46 | - { |
|
47 | - self::$table = config('irfa.rajaongkir.city_table'); |
|
48 | - self::$type = 'city'; |
|
49 | - self::_import(); |
|
50 | - } |
|
51 | - |
|
52 | - private static function formatBytes($size, $precision = 2) |
|
53 | - { |
|
54 | - $base = log($size, 1024); |
|
55 | - $suffixes = ['B', 'KB', 'MB', 'GB', 'TB']; |
|
56 | - |
|
57 | - return round(pow(1024, $base - floor($base)), $precision).' '.$suffixes[floor($base)]; |
|
58 | - } |
|
9 | + private static $bucket; |
|
10 | + private static $table; |
|
11 | + private static $type; |
|
12 | + |
|
13 | + protected static function caching($results) |
|
14 | + { |
|
15 | + self::$bucket = $results; |
|
16 | + |
|
17 | + return new static(); |
|
18 | + } |
|
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 | + } |
|
37 | + |
|
38 | + protected static function province() |
|
39 | + { |
|
40 | + self::$table = config('irfa.rajaongkir.province_table'); |
|
41 | + self::$type = 'prov'; |
|
42 | + self::_import(); |
|
43 | + } |
|
44 | + |
|
45 | + protected static function city() |
|
46 | + { |
|
47 | + self::$table = config('irfa.rajaongkir.city_table'); |
|
48 | + self::$type = 'city'; |
|
49 | + self::_import(); |
|
50 | + } |
|
51 | + |
|
52 | + private static function formatBytes($size, $precision = 2) |
|
53 | + { |
|
54 | + $base = log($size, 1024); |
|
55 | + $suffixes = ['B', 'KB', 'MB', 'GB', 'TB']; |
|
56 | + |
|
57 | + return round(pow(1024, $base - floor($base)), $precision).' '.$suffixes[floor($base)]; |
|
58 | + } |
|
59 | 59 | } |
@@ -13,108 +13,108 @@ |
||
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 getCity($arr) |
|
111 | - { |
|
112 | - $db = DB::table(config('irfa.rajaongkir.city_table')); |
|
113 | - if (!empty($arr)) { |
|
114 | - $db->where($arr); |
|
115 | - } |
|
116 | - $ret = $db->orderBy('city_name', 'ASC')->get(); |
|
117 | - |
|
118 | - return $ret; |
|
119 | - } |
|
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 getCity($arr) |
|
111 | + { |
|
112 | + $db = DB::table(config('irfa.rajaongkir.city_table')); |
|
113 | + if (!empty($arr)) { |
|
114 | + $db->where($arr); |
|
115 | + } |
|
116 | + $ret = $db->orderBy('city_name', 'ASC')->get(); |
|
117 | + |
|
118 | + return $ret; |
|
119 | + } |
|
120 | 120 | } |
@@ -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 | }); |