1 | <?php |
||||
2 | |||||
3 | namespace App\Http\Controllers; |
||||
4 | |||||
5 | use Illuminate\Http\Request; |
||||
6 | use Validator; |
||||
7 | use App\User; |
||||
8 | use App\Http\Requests; |
||||
9 | use App\Http\Controllers\Controller; |
||||
10 | use Lubus\Constants\Status; |
||||
0 ignored issues
–
show
|
|||||
11 | |||||
12 | class UsersController extends Controller |
||||
13 | { |
||||
14 | /** |
||||
15 | * Display a listing of the resource. |
||||
16 | * |
||||
17 | * @return Response |
||||
0 ignored issues
–
show
|
|||||
18 | */ |
||||
19 | public function index() |
||||
20 | { |
||||
21 | $users = user::excludeArchive()->paginate(10); |
||||
22 | |||||
23 | return view('users.index', compact('users')); |
||||
0 ignored issues
–
show
|
|||||
24 | } |
||||
25 | |||||
26 | /** |
||||
27 | * Display the specified resource. |
||||
28 | * |
||||
29 | * @param int $id |
||||
30 | * @return Response |
||||
31 | */ |
||||
32 | public function show() |
||||
33 | { |
||||
34 | $user = user::findOrFail($id); |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
35 | |||||
36 | return view('users.show', compact('user')); |
||||
0 ignored issues
–
show
|
|||||
37 | } |
||||
38 | |||||
39 | /** |
||||
40 | * Show the form for creating a new resource. |
||||
41 | * |
||||
42 | * @return Response |
||||
43 | */ |
||||
44 | public function create() |
||||
45 | { |
||||
46 | return view('users.create'); |
||||
0 ignored issues
–
show
|
|||||
47 | } |
||||
48 | |||||
49 | /** |
||||
50 | * Store a newly created resource in storage. |
||||
51 | * |
||||
52 | * @return Response |
||||
53 | */ |
||||
54 | public function store(Request $request) |
||||
55 | { |
||||
56 | $this->validate($request, ['email' => 'unique:mst_users,email']); |
||||
57 | |||||
58 | $user=array('name'=>$request->name, |
||||
59 | 'email'=> $request->email, |
||||
60 | 'photo'=> '', |
||||
61 | 'password' => bcrypt($request->password), |
||||
62 | 'status'=> $request->status); |
||||
63 | $user = new User($user); |
||||
64 | $user->save(); |
||||
65 | |||||
66 | if($user->id) |
||||
67 | { |
||||
68 | |||||
69 | $user->photo = \constFilePrefix::StaffPhoto. $user->id . '.jpg'; |
||||
0 ignored issues
–
show
|
|||||
70 | $user->save(); |
||||
71 | \Utilities::uploadFile($request,\constFilePrefix::StaffPhoto, $user->id,'photo',\constPaths::StaffPhoto); |
||||
72 | |||||
73 | flash()->success('User was successfully registered'); |
||||
74 | |||||
75 | return redirect('users'); |
||||
0 ignored issues
–
show
|
|||||
76 | } |
||||
77 | |||||
78 | else |
||||
79 | { |
||||
80 | flash()->error('Error while user registration'); |
||||
81 | return redirect('users'); |
||||
0 ignored issues
–
show
|
|||||
82 | } |
||||
83 | } |
||||
84 | |||||
85 | public function edit($id) |
||||
86 | { |
||||
87 | $user=user::findOrFail($id); |
||||
88 | |||||
89 | return view('users.edit', compact('user')); |
||||
90 | } |
||||
91 | |||||
92 | public function update($id, Request $request) |
||||
93 | { |
||||
94 | $user=user::findOrFail($id); |
||||
95 | |||||
96 | $user->name = $request->name; |
||||
97 | $user->email = $request->email; |
||||
98 | |||||
99 | if($request->password !="") |
||||
100 | { |
||||
101 | $user->password = bcrypt($request->password); |
||||
102 | } |
||||
103 | |||||
104 | $user->status = $request->status; |
||||
105 | |||||
106 | $user->update(); |
||||
107 | $user->photo = \constFilePrefix::staffPhoto. $user->id . '.jpg'; |
||||
0 ignored issues
–
show
|
|||||
108 | $user->save(); |
||||
109 | |||||
110 | \Utilities::uploadFile($request,\constFilePrefix::staffPhoto, $user->id,'photo',\constPaths::staffPhoto); |
||||
0 ignored issues
–
show
|
|||||
111 | |||||
112 | flash()->success('User details was successfully updated'); |
||||
113 | return redirect('users'); |
||||
114 | } |
||||
115 | |||||
116 | public function archive($id, Request $request) |
||||
0 ignored issues
–
show
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
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
117 | { |
||||
118 | $user=user::findOrFail($id); |
||||
119 | $user->status = \constStatus::Archive; |
||||
120 | $user->save(); |
||||
121 | flash()->error('User was successfully deleted'); |
||||
122 | return redirect('users'); |
||||
123 | } |
||||
124 | } |
||||
125 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths