Passed
Push — dev6 ( d58043...568a9a )
by Ron
17:54
created

UserSettingsController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Http\Controllers\User;
4
5
use Inertia\Inertia;
6
use Illuminate\Http\Request;
7
8
use App\Traits\UserSettingsTrait;
9
use App\Http\Controllers\Controller;
10
use App\Http\Requests\User\UpdateUserRequest;
11
use App\Http\Requests\User\UserRequest;
0 ignored issues
show
Bug introduced by
The type App\Http\Requests\User\UserRequest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use App\Models\User;
13
use Illuminate\Support\Facades\Log;
14
15
class UserSettingsController extends Controller
16
{
17
    use UserSettingsTrait;
1 ignored issue
show
Bug introduced by
The trait App\Traits\UserSettingsTrait requires the property $user_id which is not provided by App\Http\Controllers\User\UserSettingsController.
Loading history...
18
19
    /**
20
     *  Show the User Settings Page
21
     */
22
    public function index(Request $request)
23
    {
24
        return Inertia::render('User/Settings', [
25
            'user'     => $request->user()->makeVisible('user_id'),
26
            'settings' => $this->filterUserSettings($request->user()),
27
        ]);
28
    }
29
30
    /**
31
     * Show the form for creating a new resource.
32
     *
33
     * @return \Illuminate\Http\Response
34
     */
35
    public function create()
36
    {
37
        //
38
    }
39
40
    /**
41
     * Store a newly created resource in storage.
42
     *
43
     * @param  \Illuminate\Http\Request  $request
44
     * @return \Illuminate\Http\Response
45
     */
46
    public function store(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

46
    public function store(/** @scrutinizer ignore-unused */ Request $request)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
    {
48
        //
49
    }
50
51
    /**
52
     * Display the specified resource.
53
     *
54
     * @param  int  $id
55
     * @return \Illuminate\Http\Response
56
     */
57
    public function show($id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

57
    public function show(/** @scrutinizer ignore-unused */ $id)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
58
    {
59
        //
60
    }
61
62
    /**
63
     * Show the form for editing the specified resource.
64
     *
65
     * @param  int  $id
66
     * @return \Illuminate\Http\Response
67
     */
68
    public function edit($id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

68
    public function edit(/** @scrutinizer ignore-unused */ $id)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
69
    {
70
        //
71
    }
72
73
    /**
74
     *  update a users settings
75
     */
76
    public function update(UpdateUserRequest $request, $id)
77
    {
78
        $user = User::findOrFail($id);
79
        $user->update($request->toArray());
80
81
        Log::stack(['auth', 'user'])->info('User information for User '.$user->username.' (User ID - '.$user->user_id.')has been update by '.$request->user()->username);
82
83
        return back()->with([
84
            'message' => 'Account Details Updated',
85
            'type'    => 'success',
86
        ]);
87
    }
88
89
    /**
90
     * Remove the specified resource from storage.
91
     *
92
     * @param  int  $id
93
     * @return \Illuminate\Http\Response
94
     */
95
    public function destroy($id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

95
    public function destroy(/** @scrutinizer ignore-unused */ $id)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
96
    {
97
        //
98
    }
99
}
100