| Conditions | 4 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function retrieveByCredentials(array $credentials) |
||
| 17 | { |
||
| 18 | if (empty($credentials)) { |
||
| 19 | return; |
||
| 20 | } |
||
| 21 | |||
| 22 | // First we will add each credential element to the query as a where clause. |
||
| 23 | // Then we can execute the query and, if we found a user, return it in a |
||
| 24 | // Eloquent User "model" that will be utilized by the Guard instances. |
||
| 25 | $query = $this->createModel()->newQuery(); |
||
| 26 | |||
| 27 | foreach ($credentials as $key => $value) { |
||
| 28 | if (! Str::contains($key, 'password')) { |
||
| 29 | $query->whereRaw("upper({$key}) = upper(?)", [$value]); |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 33 | return $query->first(); |
||
| 34 | } |
||
| 35 | } |
||
| 36 |