Test Setup Failed
Push — master ( 8171e5...dc7c6b )
by Phan
04:40
created

ProfileController::show()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace App\Http\Controllers\API;
4
5
use App\Http\Requests\API\ProfileUpdateRequest;
6
use Hash;
7
use Illuminate\Http\JsonResponse;
8
use Illuminate\Http\Request;
9
use RuntimeException;
10
11
class ProfileController extends Controller
12
{
13
    /**
14
     * Get the current user's profile.
15
     *
16
     * @param Request $request
17
     * 
18
     * @return JsonResponse
19
     */
20
    public function show(Request $request)
21
    {
22
        return response()->json($request->user());
23
    }
24
25
    /**
26
     * Update the current user's profile.
27
     *
28
     * @param ProfileUpdateRequest $request
29
     *
30
     * @throws RuntimeException
31
     *
32
     * @return JsonResponse
33
     */
34 View Code Duplication
    public function update(ProfileUpdateRequest $request)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
    {
36
        $data = $request->only('name', 'email');
37
38
        if ($request->password) {
39
            $data['password'] = Hash::make($request->password);
40
        }
41
42
        return response()->json($request->user()->update($data));
43
    }
44
}
45