Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function get_get()
- {
- // $sekolah_datas list ALL data sekolah
- // $sekolah_data per satu sekolah
- $sekolah_datas = $this->model_gtech->get_daftar_sekolah();
- $id = $this->get('id');
- if ($id === null) {
- if ($sekolah_datas) {
- $this->response($sekolah_datas, 200);
- }
- else {
- $this->response([
- 'status' => false,
- 'message' => 'No daftar sekolah were found'
- ], 404);
- }
- }
- $id = (int) $id;
- if ($id <= 0) {
- $this->response(null, 400);
- }
- $sekolah_data = null;
- if (!empty($sekolah_datas)) {
- foreach ($sekolah_datas as $key => $value) {
- if (isset($value['id']) && $value['id'] == $id) {
- $sekolah_data = $value;
- }
- }
- }
- if (!empty($sekolah_data)) {
- $this->set_response($sekolah_data, 200);
- }
- else {
- $this->set_response([
- 'status' => false,
- 'message' => 'Data sekolah could not be found'
- ], 404);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement