Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. public function login(Request $request) {
  2.  
  3. $assistant = DB::table('assistants')
  4. ->where('username', $request->input('username'))
  5. ->where('mot_de_passe', $request->input('mot_de_passe'))
  6. ->first();
  7.  
  8.  
  9. if($assistant != null){
  10.  
  11. return response()->json ($assistant);
  12. }else{
  13. $returnData = array(
  14. 'status' => 'false',
  15. 'message' => 'write some message..');
  16. return response()->json ($returnData ,500 );
  17. }}
  18.  
  19. IAssistant iAssistant= APIClient.getClient().create(IAssistant.class);
  20.  
  21.  
  22. iAssistant.login(username.getText().toString(),password.getText().toString()).enqueue(new Callback<Assistant>() {
  23. @Override
  24. public void onResponse(retrofit2.Call<Assistant> call, Response<Assistant> response) {
  25.  
  26. if (response.isSuccessful()){
  27. startActivity(new Intent(getApplicationContext(), BottomNavigation.class));
  28. Toast.makeText(getApplicationContext(),"assistant"+response.body().getNom(),Toast.LENGTH_LONG).show();
  29.  
  30. }}
  31.  
  32. @Override
  33. public void onFailure(retrofit2.Call<Assistant> call, Throwable t) {
  34.  
  35. Toast.makeText(getApplicationContext(),"'error",Toast.LENGTH_LONG).show();
  36. Log.v("tag!!!!!!!!!!","error"+t.getMessage());
  37.  
  38. }
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement