Conditions | 2 |
Paths | 2 |
Total Lines | 21 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | public function setPolicy($request) |
||
14 | { |
||
15 | // Update the main policy |
||
16 | $this->updateSettings('auth.passwords.settings.expire', $request->expire); |
||
17 | |||
18 | // Update all users to reflect the new policy |
||
19 | if($request->expire == 0) |
||
20 | { |
||
21 | User::where('password_expires', '>', NOW())->update([ |
||
22 | 'password_expires' => null, |
||
23 | ]); |
||
24 | } |
||
25 | else |
||
26 | { |
||
27 | $newExpire = Carbon::now()->addDays($request->expire); |
||
28 | User::whereNull('password_expires')->update([ |
||
29 | 'password_expires' => $newExpire, |
||
30 | ]); |
||
31 | } |
||
32 | |||
33 | return true; |
||
34 | } |
||
36 |