Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id (integer)
- name (string)
- email (string)
- phone (string)
- codeMeli (string)
- userId (integer)
- adminId (integer)
- | id | name | email | phone | codeMeli | | userid | adminid |
- ---- ------ ------- ------- ---------- -------- ---------
- | 5 | mike | m@yaho| 12345 | 12345678 | | 6 | 5 |
- | 6 | sara | s@yaho| 54321 | 87654321 | | 7 | 5 |
- | 7 | joe | j@yaho| 56421 | 65875234 | | 7 | 8 |
- | 8 | sag | s@yaho| 57635 | 64616843 |
- Users::select('id','name','email','codeMeli','phone')
- ->join('user_admin','user_admin.userid','=','users.id')
- ->whereRaw("name LIKE '%".$name."%' and email LIKE '%".$email."%' and codeMeli LIKE '%".$codeMeli."%' and phone LIKE '%".$phone."%' and user_admin.adminid=".$CurrentUSerID)
- ->get();
- <?php
- namespace App;
- use IlluminateDatabaseEloquentModel;
- class Users extends Model
- {
- protected $table = 'users';
- public $timestamps = false;
- protected $fillable = ['name','phone','email','codeMeli','admin'];
- public function userAdmin()
- {
- return $this->belongsToMany('AppUserAdmin','id','userid');
- }
- }
- <?php
- namespace App;
- use IlluminateDatabaseEloquentModel;
- class UserAdmin extends Model
- {
- protected $table = 'user_admin';
- public $timestamps = false;
- protected $fillable = ['userid','adminid'];
- public function users()
- {
- return $this->belongsToMany('AppUsers','id','adminid');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement