Completed
Push — master ( 5eb04c...510c20 )
by
unknown
02:03 queued 41s
created

WilayahIndonesiaController   C

Complexity

Total Complexity 79

Size/Duplication

Total Lines 585
Duplicated Lines 17.95 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 105
loc 585
rs 5.442
c 2
b 0
f 0
wmc 79
lcom 1
cbo 7

25 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A provinsiindex() 0 6 1
A provinsicreate() 0 4 1
A provinsishow() 0 4 1
A provinsiedit() 0 4 1
A provinsidelete() 0 4 1
A provinsipage() 0 4 1
C provinsisearch() 26 89 7
A kabupatenindex() 0 17 1
A kabupatencreate() 0 4 1
A kabupatenshow() 0 4 1
A kabupatenedit() 0 4 1
A kabupatendelete() 0 4 1
D kabupatensearch() 35 136 19
A kecamatanindex() 0 23 1
A kecamatancreate() 0 4 1
A kecamatanshow() 0 4 1
A kecamatanedit() 0 4 1
A kecamatandelete() 0 4 1
F kecamatansearch() 44 189 31
B desaindex() 0 29 1
A desacreate() 0 4 1
A desashow() 0 4 1
A desaedit() 0 4 1
A desadelete() 0 4 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like WilayahIndonesiaController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use WilayahIndonesiaController, and based on these observations, apply Extract Interface, too.

1
<?php namespace Bantenprov\WilayahIndonesia\Http\Controllers;
2
3
use App\Http\Controllers\Controller;
4
use Illuminate\Http\Request;
5
use Bantenprov\WilayahIndonesia\Facades\WilayahIndonesia;
6
use Bantenprov\WilayahIndonesia\Models\Provinsi;
7
use Bantenprov\WilayahIndonesia\Models\Kabupaten;
8
use Bantenprov\WilayahIndonesia\Models\Kecamatan;
9
use Bantenprov\WilayahIndonesia\Models\Desa;
10
use Laravolt\Indonesia\Indonesia;
11
use Illuminate\Support\Facades\Input;
12
use Response;
13
/**
14
 * The WilayahIndonesiaController class.
15
 *
16
 * @package Bantenprov\WilayahIndonesia
17
 * @author  bantenprov <[email protected]>
18
 */
19
class WilayahIndonesiaController extends Controller
20
{
21
	protected $indonesia;
22
	protected $provinsi;
23
	protected $kabupaten;
24
	protected $kecamatan;
25
	protected $desa;
26
	
27
	public function __construct()
28
	{
29
		$this->indonesia 	= new Indonesia;
30
		$this->provinsi 	= new Provinsi;
31
		$this->kabupaten 	= new Kabupaten;
32
		$this->kecamatan 	= new Kecamatan;
33
		$this->desa 		= new Desa;
34
	}
35
	public function provinsiindex()
36
	{
37
		$page 					= 10;
38
		$data 					= $this->indonesia->paginateProvinces($page);
39
		return Response::make(json_encode($data, JSON_PRETTY_PRINT))->header('Content-Type', "application/json");
40
	}
41
	public function provinsicreate()
42
	{
43
		
44
	}
45
	public function provinsishow()
46
	{
47
		
48
	}
49
	public function provinsiedit()
50
	{
51
		
52
	}
53
	public function provinsidelete()
54
	{
55
		
56
	}
57
	public function provinsipage()
58
	{
59
		
60
	}
61
	public function provinsisearch($provinsi)
62
	{		
63
		$page 					= 10;
64
		if($provinsi == 'provinsi'){
65
			$data 					= $this->indonesia->paginateProvinces($page);			
66
		}elseif($provinsi == 'kabupaten'){
67
			$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
68
									->select(
69
										'provinces.id as province_id',
70
										'provinces.name as province_name',
71
										'cities.id as city_id',
72
										'cities.name as city_name'
73
									)
74
									->leftjoin(
75
										'cities',
76
										'provinces.id','=','cities.province_id'
77
									)
78
									->paginate($page);
79
		}elseif($provinsi == 'kecamatan'){
80
			$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
81
									->select(
82
										'provinces.id as province_id',
83
										'provinces.name as province_name',
84
										'cities.id as city_id',
85
										'cities.name as city_name',
86
										'districts.id as district_id',
87
										'districts.name as district_name'
88
									)
89
									->leftjoin(
90
										'cities',
91
										'provinces.id','=','cities.province_id'
92
									)
93
									->leftjoin(
94
										'districts',
95
										'cities.id','=','districts.city_id'
96
									)
97
									->paginate($page);
98 View Code Duplication
		}elseif($provinsi == 'desa'){
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
99
		$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
100
								->select(
101
									'provinces.id as province_id',
102
									'provinces.name as province_name',
103
									'cities.id as city_id',
104
									'cities.name as city_name',
105
									'districts.id as district_id',
106
									'districts.name as district_name',
107
									'villages.id as village_id',
108
									'villages.name as village_name'
109
								)
110
								->leftjoin(
111
									'cities',
112
									'provinces.id','=','cities.province_id'
113
								)
114
								->leftjoin(
115
									'districts',
116
									'cities.id','=','districts.city_id'
117
								)
118
								->leftjoin(
119
									'villages',
120
									'districts.id','=','villages.district_id'
121
								)
122
								->paginate($page);
123
		}else{
124
			$string 				= array('%20','+','-');
125
			foreach($string as $val){
126
				$provinsi 			= str_replace($val,' ',$provinsi);
127
			}
128
			$prov 						= $this->provinsi->where("name","=","$provinsi")->get();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
129
			if($prov->count() > 0){
130
				$provinsi 				= $prov[0]->id;
131
				$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
132
										->select(
133
											'provinces.id as province_id',
134
											'provinces.name as province_name',
135
											'cities.id as city_id',
136
											'cities.name as city_name'
137
										)
138
										->leftjoin(
139
											'cities',
140
											'provinces.id','=','cities.province_id'
141
										)
142
										->where('cities.province_id','=',$provinsi)
143
										->paginate($page);
144
			}else{
145
				$data 					= $this->indonesia->paginateProvinces($page);							
146
			}
147
		}
148
		return Response::make(json_encode($data, JSON_PRETTY_PRINT))->header('Content-Type', "application/json");
149
	}
150
	//END DATA PROVINSI
151
152
	//DATA KABUPATEN
153
	public function kabupatenindex()
154
	{	
155
		$page  					= 10;
156
		$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
157
								->select(
158
									'provinces.id as province_id',
159
									'provinces.name as province_name',
160
									'cities.id as city_id',
161
									'cities.name as city_name'
162
								)
163
								->leftjoin(
164
									'cities',
165
									'provinces.id','=','cities.province_id'
166
								)
167
								->paginate($page);
168
		return Response::make(json_encode($data, JSON_PRETTY_PRINT))->header('Content-Type', "application/json");
169
	}
170
	public function kabupatencreate()
171
	{
172
		
173
	}
174
	public function kabupatenshow()
175
	{
176
		
177
	}
178
	public function kabupatenedit()
179
	{
180
		
181
	}
182
	public function kabupatendelete()
183
	{
184
		
185
	}
186
	public function kabupatensearch($provinsi,$kabupaten)
187
	{		
188
		$page 					= 10;
189
		if($provinsi == 'provinsi'){
190
			$data 					= $this->indonesia->paginateProvinces($page);			
191
		}elseif($provinsi == 'kabupaten'){
192
			$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
193
									->select(
194
										'provinces.id as province_id',
195
										'provinces.name as province_name',
196
										'cities.id as city_id',
197
										'cities.name as city_name'
198
									)
199
									->leftjoin(
200
										'cities',
201
										'provinces.id','=','cities.province_id'
202
									)
203
									->paginate($page);
204
		}elseif($provinsi == 'kecamatan'){
205
			$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
206
									->select(
207
										'provinces.id as province_id',
208
										'provinces.name as province_name',
209
										'cities.id as city_id',
210
										'cities.name as city_name',
211
										'districts.id as district_id',
212
										'districts.name as district_name'
213
									)
214
									->leftjoin(
215
										'cities',
216
										'provinces.id','=','cities.province_id'
217
									)
218
									->leftjoin(
219
										'districts',
220
										'cities.id','=','districts.city_id'
221
									)
222
									->paginate($page);
223 View Code Duplication
		}elseif($provinsi == 'desa'){
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
224
		$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
225
								->select(
226
									'provinces.id as province_id',
227
									'provinces.name as province_name',
228
									'cities.id as city_id',
229
									'cities.name as city_name',
230
									'districts.id as district_id',
231
									'districts.name as district_name',
232
									'villages.id as village_id',
233
									'villages.name as village_name'
234
								)
235
								->leftjoin(
236
									'cities',
237
									'provinces.id','=','cities.province_id'
238
								)
239
								->leftjoin(
240
									'districts',
241
									'cities.id','=','districts.city_id'
242
								)
243
								->leftjoin(
244
									'villages',
245
									'districts.id','=','villages.district_id'
246
								)
247
								->paginate($page);
248
		}else{
249
			$string 				= array('%20','+','-');
250
			foreach($string as $val){
251
				$provinsi 			= str_replace($val,' ',$provinsi);
252
			}
253
			$prov 					= $this->provinsi->where("name","=","$provinsi")->get();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
254
			if($prov->count() > 0){
255
				$provinsi 				= $prov[0]->id;
256
				foreach($string as $val){
257
					$kabupaten 				= str_replace($val,' ',$kabupaten);
258
				}
259
				$kab 						= $this->kabupaten->where("province_id","=","$provinsi")->where("name","=","$kabupaten")->get();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Bantenprov\Wilaya...nesia\Models\Kabupaten>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
260
				if($kab->count() == 0){
261
					$kabupaten 				= 'kabupaten '.$kabupaten;
262
				}
263
				$kab1 						= $this->kabupaten->where("province_id","=","$provinsi")->where("name","=","$kabupaten")->get();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Bantenprov\Wilaya...nesia\Models\Kabupaten>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
264
				if($kab1->count() == 0){
265
					$kabupaten 				= 'kab '.$kabupaten;
266
				}
267
				$kab2 						= $this->kabupaten->where("province_id","=","$provinsi")->where("name","=","$kabupaten")->get();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Bantenprov\Wilaya...nesia\Models\Kabupaten>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
268
				if($kab2->count() == 0){
269
					$kabupaten 				= 'kab. '.$kabupaten;
270
				}
271
				$kab3 						= $this->kabupaten->where("province_id","=","$provinsi")->where("name","=","$kabupaten")->get();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Bantenprov\Wilaya...nesia\Models\Kabupaten>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
272
				if(($kab->count() > 0) || ($kab1->count() > 0) || ($kab2->count() > 0) || ($kab3->count() > 0)){
273 View Code Duplication
					if(isset($kab[0]->id)){
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
274
						$kabupaten 			= $kab[0]->id;
275
					}elseif(isset($kab1[0]->id)){
276
						$kabupaten 			= $kab1[0]->id;						
277
					}elseif(isset($kab2[0]->id)){
278
						$kabupaten 			= $kab2[0]->id;						
279
					}elseif(isset($kab3[0]->id)){
280
						$kabupaten 			= $kab3[0]->id;						
281
					}
282
					$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
283
											->select(
284
												'provinces.id as province_id',
285
												'provinces.name as province_name',
286
												'cities.id as city_id',
287
												'cities.name as city_name',
288
												'districts.id as district_id',
289
												'districts.name as district_name'
290
											)
291
											->leftjoin(
292
												'cities',
293
												'provinces.id','=','cities.province_id'
294
											)
295
											->leftjoin(
296
												'districts',
297
												'cities.id','=','districts.city_id'
298
											)
299
											->where('districts.city_id','=',$kabupaten)
300
											->paginate($page);
301
				}else{
302
					$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
303
											->select(
304
												'provinces.id as province_id',
305
												'provinces.name as province_name',
306
												'cities.id as city_id',
307
												'cities.name as city_name'
308
											)
309
											->leftjoin(
310
												'cities',
311
												'provinces.id','=','cities.province_id'
312
											)
313
											->where('cities.province_id','=',$provinsi)
314
											->paginate($page);
315
				}
316
			}else{
317
				$data 					= $this->indonesia->paginateProvinces($page);							
318
			}
319
		}
320
		return Response::make(json_encode($data, JSON_PRETTY_PRINT))->header('Content-Type', "application/json");
321
	}
322
	//END DATA KABUPATEN
323
	
324
	//DATA KECAMATAN
325
	public function kecamatanindex()
326
	{
327
		$page  					= 10;
328
		$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
329
								->select(
330
									'provinces.id as province_id',
331
									'provinces.name as province_name',
332
									'cities.id as city_id',
333
									'cities.name as city_name',
334
									'districts.id as district_id',
335
									'districts.name as district_name'
336
								)
337
								->leftjoin(
338
									'cities',
339
									'provinces.id','=','cities.province_id'
340
								)
341
								->leftjoin(
342
									'districts',
343
									'cities.id','=','districts.city_id'
344
								)
345
								->paginate($page);
346
		return Response::make(json_encode($data, JSON_PRETTY_PRINT))->header('Content-Type', "application/json");		
347
	}
348
	public function kecamatancreate()
349
	{
350
		
351
	}
352
	public function kecamatanshow()
353
	{
354
		
355
	}
356
	public function kecamatanedit()
357
	{
358
		
359
	}
360
	public function kecamatandelete()
361
	{
362
		
363
	}
364
	public function kecamatansearch($provinsi,$kabupaten,$kecamatan)
365
	{		
366
		$page 					= 10;
367
		if($provinsi == 'provinsi'){
368
			$data 					= $this->indonesia->paginateProvinces($page);			
369
		}elseif($provinsi == 'kabupaten'){
370
			$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
371
									->select(
372
										'provinces.id as province_id',
373
										'provinces.name as province_name',
374
										'cities.id as city_id',
375
										'cities.name as city_name'
376
									)
377
									->leftjoin(
378
										'cities',
379
										'provinces.id','=','cities.province_id'
380
									)
381
									->paginate($page);
382
		}elseif($provinsi == 'kecamatan'){
383
			$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
384
									->select(
385
										'provinces.id as province_id',
386
										'provinces.name as province_name',
387
										'cities.id as city_id',
388
										'cities.name as city_name',
389
										'districts.id as district_id',
390
										'districts.name as district_name'
391
									)
392
									->leftjoin(
393
										'cities',
394
										'provinces.id','=','cities.province_id'
395
									)
396
									->leftjoin(
397
										'districts',
398
										'cities.id','=','districts.city_id'
399
									)
400
									->paginate($page);
401 View Code Duplication
		}elseif($provinsi == 'desa'){
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
402
		$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
403
								->select(
404
									'provinces.id as province_id',
405
									'provinces.name as province_name',
406
									'cities.id as city_id',
407
									'cities.name as city_name',
408
									'districts.id as district_id',
409
									'districts.name as district_name',
410
									'villages.id as village_id',
411
									'villages.name as village_name'
412
								)
413
								->leftjoin(
414
									'cities',
415
									'provinces.id','=','cities.province_id'
416
								)
417
								->leftjoin(
418
									'districts',
419
									'cities.id','=','districts.city_id'
420
								)
421
								->leftjoin(
422
									'villages',
423
									'districts.id','=','villages.district_id'
424
								)
425
								->paginate($page);
426
		}else{
427
			$string 				= array('%20','+','-');
428
			foreach($string as $val){
429
				$provinsi 			= str_replace($val,' ',$provinsi);
430
			}
431
			$prov 					= $this->provinsi->where("name","=","$provinsi")->get();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
432
			if($prov->count() > 0){
433
				$provinsi 				= $prov[0]->id;
434
				foreach($string as $val){
435
					$kabupaten 				= str_replace($val,' ',$kabupaten);
436
				}
437
				$kab 						= $this->kabupaten->where("province_id","=","$provinsi")->where("name","=","$kabupaten")->get();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Bantenprov\Wilaya...nesia\Models\Kabupaten>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
438
				if($kab->count() == 0){
439
					$kabupaten 				= 'kabupaten '.$kabupaten;
440
				}
441
				$kab1 						= $this->kabupaten->where("province_id","=","$provinsi")->where("name","=","$kabupaten")->get();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Bantenprov\Wilaya...nesia\Models\Kabupaten>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
442
				if($kab1->count() == 0){
443
					$kabupaten 				= 'kab '.$kabupaten;
444
				}
445
				$kab2 						= $this->kabupaten->where("province_id","=","$provinsi")->where("name","=","$kabupaten")->get();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Bantenprov\Wilaya...nesia\Models\Kabupaten>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
446
				if($kab2->count() == 0){
447
					$kabupaten 				= 'kab. '.$kabupaten;
448
				}
449
				$kab3 						= $this->kabupaten->where("province_id","=","$provinsi")->where("name","=","$kabupaten")->get();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Bantenprov\Wilaya...nesia\Models\Kabupaten>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
450
				if(($kab->count() > 0) || ($kab1->count() > 0) || ($kab2->count() > 0) || ($kab3->count() > 0)){
451 View Code Duplication
					if(isset($kab[0]->id)){
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
452
						$kabupaten 			= $kab[0]->id;
453
					}elseif(isset($kab1[0]->id)){
454
						$kabupaten 			= $kab1[0]->id;						
455
					}elseif(isset($kab2[0]->id)){
456
						$kabupaten 			= $kab2[0]->id;						
457
					}elseif(isset($kab3[0]->id)){
458
						$kabupaten 			= $kab3[0]->id;						
459
					}
460
					foreach($string as $val){
461
						$kecamatan 				= str_replace($val,' ',$kecamatan);
462
					}
463
					$kec 						= $this->kecamatan->where("city_id","=","$kabupaten")->where("name","=","$kecamatan")->get();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Bantenprov\Wilaya...nesia\Models\Kecamatan>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
464
					if($kec->count() == 0){
465
						$kecamatan 				= 'kecamatan '.$kecamatan;
466
					}
467
					$kec1 						= $this->kecamatan->where("city_id","=","$kabupaten")->where("name","=","$kecamatan")->get();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Bantenprov\Wilaya...nesia\Models\Kecamatan>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
468
					if($kec1->count() == 0){
469
						$kecamatan 				= 'kec '.$kecamatan;
470
					}
471
					$kec2 						= $this->kecamatan->where("city_id","=","$kabupaten")->where("name","=","$kecamatan")->get();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Bantenprov\Wilaya...nesia\Models\Kecamatan>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
472
					if($kec2->count() == 0){
473
						$kecamatan 				= 'kec. '.$kecamatan;
474
					}
475
					$kec3 						= $this->kecamatan->where("city_id","=","$kabupaten")->where("name","=","$kecamatan")->get();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Bantenprov\Wilaya...nesia\Models\Kecamatan>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
476
					if(($kec->count() > 0) || ($kec1->count() > 0) || ($kec2->count() > 0) || ($kec3->count() > 0)){
477 View Code Duplication
						if(isset($kec[0]->id)){
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
478
							$kecamatan 			= $kec[0]->id;
479
						}elseif(isset($kec1[0]->id)){
480
							$kecamatan 			= $kec1[0]->id;						
481
						}elseif(isset($kec2[0]->id)){
482
							$kecamatan 			= $kec2[0]->id;						
483
						}elseif(isset($kec3[0]->id)){
484
							$kecamatan 			= $kec3[0]->id;						
485
						}
486
						$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
487
												->select(
488
													'provinces.id as province_id',
489
													'provinces.name as province_name',
490
													'cities.id as city_id',
491
													'cities.name as city_name',
492
													'districts.id as district_id',
493
													'districts.name as district_name',
494
													'villages.id as village_id',
495
													'villages.name as village_name'
496
												)
497
												->leftjoin(
498
													'cities',
499
													'provinces.id','=','cities.province_id'
500
												)
501
												->leftjoin(
502
													'districts',
503
													'cities.id','=','districts.city_id'
504
												)
505
												->leftjoin(
506
													'villages',
507
													'districts.id','=','villages.district_id'
508
												)
509
												->where('villages.district_id','=',$kecamatan)
510
												->paginate($page);
511
					}else{
512
						$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
513
												->select(
514
													'provinces.id as province_id',
515
													'provinces.name as province_name',
516
													'cities.id as city_id',
517
													'cities.name as city_name',
518
													'districts.id as district_id',
519
													'districts.name as district_name'
520
												)
521
												->leftjoin(
522
													'cities',
523
													'provinces.id','=','cities.province_id'
524
												)
525
												->leftjoin(
526
													'districts',
527
													'cities.id','=','districts.city_id'
528
												)
529
												->where('districts.city_id','=',$kabupaten)
530
												->paginate($page);						
531
					}
532
				}else{
533
					$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
534
											->select(
535
												'provinces.id as province_id',
536
												'provinces.name as province_name',
537
												'cities.id as city_id',
538
												'cities.name as city_name'
539
											)
540
											->leftjoin(
541
												'cities',
542
												'provinces.id','=','cities.province_id'
543
											)
544
											->where('cities.province_id','=',$provinsi)
545
											->paginate($page);
546
				}
547
			}else{
548
				$data 					= $this->indonesia->paginateProvinces($page);							
549
			}
550
		}
551
		return Response::make(json_encode($data, JSON_PRETTY_PRINT))->header('Content-Type', "application/json");
552
	}
553
	//END DATA KECAMATAN
554
555
	//DATA DESA
556
	public function desaindex()
557
	{
558
		$page  					= 10;
559
		$data 					= $this->provinsi
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<Bantenprov\Wilaya...onesia\Models\Provinsi>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
560
								->select(
561
									'provinces.id as province_id',
562
									'provinces.name as province_name',
563
									'cities.id as city_id',
564
									'cities.name as city_name',
565
									'districts.id as district_id',
566
									'districts.name as district_name',
567
									'villages.id as village_id',
568
									'villages.name as village_name'
569
								)
570
								->leftjoin(
571
									'cities',
572
									'provinces.id','=','cities.province_id'
573
								)
574
								->leftjoin(
575
									'districts',
576
									'cities.id','=','districts.city_id'
577
								)
578
								->leftjoin(
579
									'villages',
580
									'districts.id','=','villages.district_id'
581
								)
582
								->paginate($page);
583
		return Response::make(json_encode($data, JSON_PRETTY_PRINT))->header('Content-Type', "application/json");		
584
	}
585
	public function desacreate()
586
	{
587
		
588
	}
589
	public function desashow()
590
	{
591
		
592
	}
593
	public function desaedit()
594
	{
595
		
596
	}
597
	public function desadelete()
598
	{
599
		
600
	}
601
	//END DATA DESA
602
	
603
}
604