ProfileController::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Http\Requests\UpdateProfile;
6
use Illuminate\Support\Facades\Auth;
7
use Illuminate\Support\Facades\Hash;
8
use Illuminate\Support\Facades\Log;
9
10
class ProfileController extends Controller
11
{
12
    public function get()
13
    {
14
        return view('profile');
15
    }
16
17
    public function update(UpdateProfile $request)
18
    {
19
        $validated = $request->validated();
20
        $user = Auth::user();
21
        if ($validated['name']) {
22
            $user->name = $validated['name'];
23
            Log::info('User#' . $user->id . ' changed its name to ' . $validated['name']);
24
        }
25
        if ($validated['password']) {
26
            $user->password = Hash::make($validated['password']);
27
            Log::info('User#' . $user->id . ' changed its password');
28
        }
29
        $user->save();
30
        return redirect()->route('profile.show')->with('status', 'Updated profile successfully!');
31
    }
32
}
33