Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. id (integer)
  2. name (string)
  3. email (string)
  4. phone (string)
  5. codeMeli (string)
  6.  
  7. userId (integer)
  8. adminId (integer)
  9.  
  10. | id | name | email | phone | codeMeli | | userid | adminid |
  11. ---- ------ ------- ------- ---------- -------- ---------
  12. | 5 | mike | m@yaho| 12345 | 12345678 | | 6 | 5 |
  13. | 6 | sara | s@yaho| 54321 | 87654321 | | 7 | 5 |
  14. | 7 | joe | j@yaho| 56421 | 65875234 | | 7 | 8 |
  15. | 8 | sag | s@yaho| 57635 | 64616843 |
  16.  
  17. Users::select('id','name','email','codeMeli','phone')
  18. ->join('user_admin','user_admin.userid','=','users.id')
  19. ->whereRaw("name LIKE '%".$name."%' and email LIKE '%".$email."%' and codeMeli LIKE '%".$codeMeli."%' and phone LIKE '%".$phone."%' and user_admin.adminid=".$CurrentUSerID)
  20. ->get();
  21.  
  22. <?php
  23. namespace App;
  24. use IlluminateDatabaseEloquentModel;
  25.  
  26. class Users extends Model
  27. {
  28. protected $table = 'users';
  29. public $timestamps = false;
  30. protected $fillable = ['name','phone','email','codeMeli','admin'];
  31.  
  32. public function userAdmin()
  33. {
  34. return $this->belongsToMany('AppUserAdmin','id','userid');
  35. }
  36. }
  37.  
  38. <?php
  39. namespace App;
  40. use IlluminateDatabaseEloquentModel;
  41.  
  42. class UserAdmin extends Model
  43. {
  44. protected $table = 'user_admin';
  45. public $timestamps = false;
  46. protected $fillable = ['userid','adminid'];
  47.  
  48. public function users()
  49. {
  50. return $this->belongsToMany('AppUsers','id','adminid');
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement