murrant /
librenmsv2
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Http\Controllers; |
||
| 4 | |||
| 5 | use App\DataTables\General\UserDataTable; |
||
| 6 | use App\Http\Requests\CreateUserRequest; |
||
| 7 | use App\Http\Requests\DeleteUserRequest; |
||
| 8 | use App\Http\Requests\UpdateUserRequest; |
||
| 9 | use App\Models\User; |
||
| 10 | use Auth; |
||
| 11 | use Dingo\Api\Routing\Helpers; |
||
| 12 | use Illuminate\Http\Request; |
||
| 13 | |||
| 14 | class UserController extends Controller |
||
| 15 | { |
||
| 16 | use Helpers; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Display a listing of the resource. |
||
| 20 | * |
||
| 21 | * @param UserDataTable $dataTable |
||
| 22 | * @return \Illuminate\Http\Response |
||
|
0 ignored issues
–
show
|
|||
| 23 | */ |
||
| 24 | 1 | public function index(UserDataTable $dataTable) |
|
| 25 | { |
||
| 26 | 1 | if (Auth::user()->isAdmin()) { |
|
| 27 | 1 | return $dataTable->render('users.manage'); |
|
| 28 | } |
||
| 29 | return redirect('preferences'); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Show the form for creating a new resource. |
||
| 34 | * |
||
| 35 | * @return \Illuminate\Http\Response |
||
|
0 ignored issues
–
show
|
|||
| 36 | */ |
||
| 37 | public function create() |
||
| 38 | { |
||
| 39 | return view('users.create'); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Store a newly created resource in storage. |
||
| 44 | * |
||
| 45 | * @param CreateUserRequest $request |
||
| 46 | * @return \Illuminate\Http\Response |
||
|
0 ignored issues
–
show
|
|||
| 47 | */ |
||
| 48 | public function store(CreateUserRequest $request) |
||
| 49 | { |
||
| 50 | $user = User::create($request->all()); |
||
|
0 ignored issues
–
show
|
|||
| 51 | |||
| 52 | return response()->json(['message' => trans('user.text.created', ['username' => $user->username])]); |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Display the specified resource. |
||
| 57 | * |
||
| 58 | * @param int $user_id |
||
| 59 | * @return \Illuminate\Http\Response |
||
|
0 ignored issues
–
show
|
|||
| 60 | */ |
||
| 61 | public function show($user_id) |
||
|
0 ignored issues
–
show
|
|||
| 62 | { |
||
| 63 | // show read only view of user info here |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Show the form for editing the specified resource. |
||
| 68 | * |
||
| 69 | * @param int $user_id |
||
| 70 | * @return \Illuminate\Http\Response |
||
| 71 | */ |
||
| 72 | 1 | public function edit($user_id) |
|
| 73 | { |
||
| 74 | 1 | $user = User::with('devices', 'ports')->findOrFail($user_id); |
|
|
0 ignored issues
–
show
The method
findOrFail does only exist in Illuminate\Database\Eloquent\Builder, but not in Illuminate\Database\Eloquent\Model.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 75 | |||
| 76 | 1 | if (Auth::user()->isAdmin()) { |
|
| 77 | 1 | return view('users.edit')->withUser($user); |
|
| 78 | } |
||
| 79 | |||
| 80 | return redirect('preferences'); |
||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Show the user's preference page |
||
| 85 | * |
||
| 86 | * @return \Illuminate\Http\Response |
||
|
0 ignored issues
–
show
|
|||
| 87 | */ |
||
| 88 | 4 | public function preferences() |
|
| 89 | { |
||
| 90 | 4 | $user = Auth::user(); |
|
| 91 | |||
| 92 | 4 | $device_count = $user->devices()->count(); |
|
| 93 | 4 | $port_count = $user->ports()->count(); |
|
| 94 | |||
| 95 | 4 | return view('users.preferences', compact('device_count', 'port_count')); |
|
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * Update the specified resource in storage. |
||
| 100 | * |
||
| 101 | * @param UpdateUserRequest|Request $request |
||
| 102 | * @param $user_id |
||
| 103 | * @return \Illuminate\Http\Response |
||
| 104 | */ |
||
| 105 | public function update(UpdateUserRequest $request, $user_id) |
||
| 106 | { |
||
| 107 | $user = User::find($user_id); |
||
| 108 | $user->update($request->all()); |
||
| 109 | if ($request->input('update') == 'password') { |
||
| 110 | $message = trans('user.text.pwdupdated'); |
||
| 111 | } else { |
||
| 112 | $message = trans('user.text.updated', ['username' => $user->username]); |
||
| 113 | } |
||
| 114 | |||
| 115 | return redirect()->back()->with(['type' => 'success', 'message' => $message]); |
||
| 116 | } |
||
| 117 | |||
| 118 | /** |
||
| 119 | * Remove the specified resource from storage. |
||
| 120 | * |
||
| 121 | * @param int $user_id |
||
| 122 | * @return \Illuminate\Http\Response |
||
|
0 ignored issues
–
show
|
|||
| 123 | */ |
||
| 124 | public function destroy(DeleteUserRequest $request, $user_id) |
||
| 125 | { |
||
| 126 | $user = User::find($user_id); |
||
| 127 | $user->delete(); |
||
| 128 | |||
| 129 | return response()->json(['message' => trans('user.text.deleted', ['username' => $user->username])]); |
||
| 130 | } |
||
| 131 | } |
||
| 132 |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.