| Conditions | 3 |
| Paths | 4 |
| Total Lines | 20 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace Usman\Guardian\Repositories; |
||
| 16 | public function searchUserByRole($username, $role, $perPage = self::PAGE) |
||
| 17 | { |
||
| 18 | |||
| 19 | $query = $this->model->query(); |
||
| 20 | |||
| 21 | if( ! empty($username)) |
||
| 22 | { |
||
| 23 | $query->where('username','LIKE','%'.$username.'%'); |
||
| 24 | } |
||
| 25 | |||
| 26 | if( ! empty($role)) |
||
| 27 | { |
||
| 28 | $query->whereHas('roles',function($query) use ($role) |
||
| 29 | { |
||
| 30 | $query->where('role_name','=',$role); |
||
| 31 | }); |
||
| 32 | } |
||
| 33 | |||
| 34 | return $query->with('roles')->paginate($perPage); |
||
| 35 | } |
||
| 36 | |||
| 50 | } |