public function getDesaByKecamatanID($kecamatan_id) { $res = Desa::whereHas('kecamatan', function ($q) use($kecamatan_id) { $q->where('id', '=', $kecamatan_id); })->get(); return $res->toJSON(); }
public static function search($keyword) { $desa = Desa::whereHas('kecamatan', function ($q) use($keyword) { $q->whereHas("kabkota", function ($q) use($keyword) { $q->whereHas('provinsi', function ($q) use($keyword) { $q->where('nama', 'LIKE', '%' . $keyword . '%'); })->where('nama', 'LIKE', '%' . $keyword . '%'); })->where('nama', 'LIKE', '%' . $keyword . '%'); })->orWhere('id', 'LIKE', '%' . $keyword . '%')->orWhere('nama', 'LIKE', '%' . $keyword . '%'); return $desa; }