| @@ 79-90 (lines=12) @@ | ||
| 76 | * @param Agent $agent |
|
| 77 | * @return Device|null |
|
| 78 | */ |
|
| 79 | public function findUserDeviceByAgent(Authenticatable $user, Agent $agent) |
|
| 80 | { |
|
| 81 | if (!$user->hasDevices()) { |
|
| 82 | return null; |
|
| 83 | } |
|
| 84 | ||
| 85 | $matching = $user->devices->filter(function ($item) use ($agent) { |
|
| 86 | return $this->deviceMatch($item, $agent); |
|
| 87 | })->first(); |
|
| 88 | ||
| 89 | return $matching ? $matching : null; |
|
| 90 | } |
|
| 91 | ||
| 92 | /** |
|
| 93 | * @param Model $user |
|
| @@ 135-146 (lines=12) @@ | ||
| 132 | * @param Agent $agent |
|
| 133 | * @return false|Device |
|
| 134 | */ |
|
| 135 | public function findDeviceForUser(Model $user, Agent $agent) |
|
| 136 | { |
|
| 137 | if (!$user->hasDevices()) { |
|
| 138 | return false; |
|
| 139 | } |
|
| 140 | ||
| 141 | $device = $user->devices->filter(function ($item) use ($agent) { |
|
| 142 | return $this->deviceMatch($item, $agent); |
|
| 143 | })->first(); |
|
| 144 | ||
| 145 | return is_null($device) ? false : $device; |
|
| 146 | } |
|
| 147 | ||
| 148 | /** |
|
| 149 | * @param Device $device |
|