1 | <?php |
||||||
2 | |||||||
3 | namespace App\Http\Controllers; |
||||||
4 | |||||||
5 | use App\Http\Requests\DestroyUser; |
||||||
6 | use App\Http\Requests\ListUser; |
||||||
7 | use App\Http\Requests\ShowUser; |
||||||
8 | use App\Http\Requests\StoreUser; |
||||||
9 | use App\Http\Requests\UpdateUser; |
||||||
10 | use App\User; |
||||||
11 | use Illuminate\Http\Request; |
||||||
12 | |||||||
13 | class ApiUserController extends Controller |
||||||
14 | { |
||||||
15 | public function index(ListUser $request) |
||||||
0 ignored issues
–
show
|
|||||||
16 | { |
||||||
17 | return User::all(); |
||||||
18 | } |
||||||
19 | |||||||
20 | public function show(ShowUser $user) |
||||||
21 | { |
||||||
22 | return $user; |
||||||
23 | } |
||||||
24 | |||||||
25 | //La funció del request s'anomena injeccio de dependències. |
||||||
26 | public function store(StoreUser $request) |
||||||
27 | { |
||||||
28 | $request->validate([ |
||||||
0 ignored issues
–
show
The call to
Illuminate\Foundation\Http\FormRequest::validate() has too many arguments starting with array('name' => 'require...d' => 'required|min:6') .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||||
29 | 'name' => 'required|max:255', |
||||||
30 | 'username' => 'sometimes|required|max:255|unique:users', |
||||||
31 | 'email' => 'required|email|max:255|unique:users', |
||||||
32 | 'password' => 'required|min:6', |
||||||
33 | ]); |
||||||
34 | |||||||
35 | $user = User::create([ |
||||||
36 | 'name' => $request->name, |
||||||
37 | 'username' => $request->username, |
||||||
38 | 'email' => $request->email, |
||||||
39 | 'password' => bcrypt($request->password), |
||||||
40 | ]); |
||||||
41 | |||||||
42 | return $user; |
||||||
43 | } |
||||||
44 | |||||||
45 | public function destroy(DestroyUser $user) |
||||||
46 | { |
||||||
47 | //el User $user és equivalent a $user = User::findOrFail($id) |
||||||
48 | |||||||
49 | $user->delete(); |
||||||
0 ignored issues
–
show
The method
delete() does not exist on App\Http\Requests\DestroyUser . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
50 | |||||||
51 | return $user; |
||||||
52 | } |
||||||
53 | |||||||
54 | public function update(UpdateUser $request, User $user) |
||||||
55 | { |
||||||
56 | $request->validate([ |
||||||
0 ignored issues
–
show
The call to
Illuminate\Foundation\Http\FormRequest::validate() has too many arguments starting with array('name' => 'required') .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||||
57 | 'name' => 'required', |
||||||
58 | ]); |
||||||
59 | |||||||
60 | $user->name = $request->name; |
||||||
0 ignored issues
–
show
The property
name does not exist on App\User . Since you implemented __set , consider adding a @property annotation.
![]() |
|||||||
61 | $user->save(); |
||||||
62 | |||||||
63 | return $user; |
||||||
64 | } |
||||||
65 | } |
||||||
66 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.