Advertisement
Guest User

getRestApi

a guest
Dec 11th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. public function index_get(){
  2.  
  3. $id = $this->get('id');
  4.  
  5. if ($id === null) {
  6.  
  7. $mahasiswa = $this->mahasiswa->getMahasiswa();
  8.  
  9. }else{
  10.  
  11. $query = "SELECT * FROM mahasiswa where id = 51";
  12. $mahasiswa = $this->mahasiswa->getMahasiswa($query);
  13.  
  14. }
  15.  
  16.  
  17.  
  18. if($mahasiswa){
  19.  
  20. $this->response([
  21. 'status' => true,
  22. 'data' => $mahasiswa
  23. ], REST_Controller::HTTP_OK);
  24. }else{
  25.  
  26. $this->response([
  27. 'status' => false,
  28. 'message' => 'id not found'
  29. ], REST_Controller::HTTP_NOT_FOUND);
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement