| Conditions | 5 |
| Paths | 8 |
| Total Lines | 34 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 21 | public function preferences(Request $request) { |
||
| 22 | |||
| 23 | $method = $request->method(); |
||
| 24 | $updated = false; |
||
| 25 | if ($request->user()->hasGlobalRead() === true) |
||
| 26 | { |
||
| 27 | $devices = []; |
||
| 28 | $ports = []; |
||
| 29 | } |
||
| 30 | else { |
||
| 31 | $devices = User::find($request->user()->user_id)->devices()->count(); |
||
| 32 | $ports = User::find($request->user()->user_id)->ports()->count(); |
||
| 33 | } |
||
| 34 | |||
| 35 | if ($method === "POST") |
||
| 36 | { |
||
| 37 | $this->validate($request, [ |
||
| 38 | 'current_password' => 'required|max:255', |
||
| 39 | 'new_password' => 'required|min:8|max:255', |
||
| 40 | 'repeat_password' => 'required|same:new_password|min:8|max:255', |
||
| 41 | ]); |
||
| 42 | if (!Hash::check($request->current_password, $request->user()->password)) |
||
| 43 | { |
||
| 44 | return back()->withInput()->withErrors(['current_password'=>'Current password is incorrect']); |
||
| 45 | } |
||
| 46 | $user = User::where('user_id', $request->user()->user_id)->first(); |
||
| 47 | $user->password = Hash::make($request->new_password); |
||
| 48 | if ($user->save()) |
||
| 49 | { |
||
| 50 | $updated = true; |
||
| 51 | } |
||
| 52 | } |
||
| 53 | return view('users.preferences', ['updated' => $updated, 'devices' => $devices, 'ports' => $ports]); |
||
| 54 | } |
||
| 55 | } |
||
| 56 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.