Referensi.php
2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
/**
* @Author: irul
* @Date: 2019-09-20 23:05:52
* @Last Modified by: irul
* @Last Modified time: 2019-10-01 23:43:20
*/
namespace Integrasi\Reklame\Base;
use \Illuminate\Database\Eloquent\ModelNotFoundException;
/**
* Daftar method (global) yang digunakan untuk semua daerah.
* Pengelompokan berdasarkan data pendukung.
*/
class Referensi extends AbstractClass
{
public static function getKecamatan()
{
// return Models\Kecamatan::all()->toJson();
// $data = Models\Kecamatan::where('enabled', 1)->get();
// $data = Models\Kecamatan::whereEnabled(1)->get();
$data = call_user_func(self::getParentNamespace() . '\Models\Kecamatan::whereEnabled', 1)
->get();
if (!count($data)) {
throw new ModelNotFoundException(MSG_NOT_FOUND);
}
return $data;
}
public static function getKecamatanById($id)
{
// $data = Models\Kecamatan::whereEnabled(1)->find($id);
$data = call_user_func(self::getParentNamespace() . '\Models\Kecamatan::whereEnabled', 1)
->find($id);
if (!$data) {
throw new ModelNotFoundException(MSG_NOT_FOUND);
}
return $data;
}
public static function getKelurahan()
{
// $data = Models\Kelurahan::whereEnabled(1)->get();
$data = call_user_func(self::getParentNamespace() . '\Models\Kelurahan::whereEnabled', 1)
->get();
if (!count($data)) {
throw new ModelNotFoundException(MSG_NOT_FOUND);
}
return $data;
}
public static function getKelurahanById($id)
{
// $data = Models\Kelurahan::whereEnabled(1)->find($id);
$data = call_user_func(self::getParentNamespace() . '\Models\Kelurahan::whereEnabled', 1)
->find($id);
if (!$data) {
throw new ModelNotFoundException(MSG_NOT_FOUND);
}
return $data;
}
public static function getKelurahanByKecamatanId($kecamatan_id)
{
// $data = Models\Kelurahan::whereRaw('enabled = 1 and kecamatan_id = ?', array($kecamatan_id))->get();
// $data = Models\Kelurahan::whereEnabled(1)->whereKecamatan_id($kecamatan_id)->get();
$data = call_user_func(self::getParentNamespace() . '\Models\Kelurahan::whereEnabled', 1)
->whereKecamatan_id($kecamatan_id)
->get();
if (!count($data)) {
throw new ModelNotFoundException(MSG_NOT_FOUND);
}
return $data;
}
public static function getPajakReklame()
{
// $data = Models\Pajak::whereEnabled(1)->whereUsahaId(DEFAULT_USAHA_ID)->get();
$data = call_user_func(self::getParentNamespace() . '\Models\Pajak::whereEnabled', 1)
->whereUsahaId(DEFAULT_USAHA_ID)
->get();
if (!count($data)) {
throw new ModelNotFoundException(MSG_NOT_FOUND);
}
return $data;
}
public static function getPajakReklameById($id)
{
// $data = Models\Pajak::whereEnabled(1)->whereUsahaId(DEFAULT_USAHA_ID)->find($id);
$data = call_user_func(self::getParentNamespace() . '\Models\Pajak::whereEnabled', 1)
->whereUsahaId(DEFAULT_USAHA_ID)
->find($id);
if (!$data) {
throw new ModelNotFoundException(MSG_NOT_FOUND);
}
return $data;
}
}