1 | <?php |
||||||
2 | |||||||
3 | namespace App\Http\Controllers; |
||||||
4 | |||||||
5 | use App\Http\Requests\DestroyTask; |
||||||
6 | use App\Http\Requests\ListTask; |
||||||
7 | use App\Http\Requests\ShowTask; |
||||||
8 | use App\Http\Requests\StoreTask; |
||||||
9 | use App\Http\Requests\UpdateTask; |
||||||
10 | use App\Task; |
||||||
11 | use Illuminate\Http\Request; |
||||||
12 | |||||||
13 | /** |
||||||
14 | * Class ApiTaskController. |
||||||
15 | */ |
||||||
16 | class ApiTaskController extends Controller |
||||||
17 | { |
||||||
18 | /** |
||||||
19 | * @param ListTask $request |
||||||
20 | * |
||||||
21 | * @return \Illuminate\Database\Eloquent\Collection|static[] |
||||||
22 | */ |
||||||
23 | public function index(ListTask $request) |
||||||
0 ignored issues
–
show
|
|||||||
24 | { |
||||||
25 | return Task::all(); |
||||||
26 | } |
||||||
27 | |||||||
28 | /** |
||||||
29 | * @param Task $task |
||||||
30 | * |
||||||
31 | * @return Task |
||||||
32 | */ |
||||||
33 | public function show(ShowTask $request, Task $task) |
||||||
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. ![]() |
|||||||
34 | { |
||||||
35 | //return $this->Object->show($task); això era per retornar el nom, es fara més avant. |
||||||
36 | return $task; |
||||||
37 | } |
||||||
38 | |||||||
39 | //La funció del request s'anomena injeccio de dependències. |
||||||
40 | |||||||
41 | /** |
||||||
42 | * @param StoreTask $request a mida, quines normes de validació a de complir aquella request. |
||||||
43 | * |
||||||
44 | * @return mixed |
||||||
45 | */ |
||||||
46 | public function store(StoreTask $request) |
||||||
47 | { |
||||||
48 | $request->validate([ |
||||||
0 ignored issues
–
show
The call to
Illuminate\Foundation\Http\FormRequest::validate() has too many arguments starting with array('name' => 'require...ription' => '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. ![]() |
|||||||
49 | 'name' => 'required', |
||||||
50 | 'user_id' => 'required', |
||||||
51 | 'description' => 'required', |
||||||
52 | ]); |
||||||
53 | |||||||
54 | $task = Task::create($request->only(['name', 'user_id', 'description'])); |
||||||
55 | |||||||
56 | return $task; |
||||||
57 | } |
||||||
58 | |||||||
59 | /** |
||||||
60 | * @param DestroyTask $request |
||||||
61 | * @param Task $task |
||||||
62 | * |
||||||
63 | * @return Task |
||||||
64 | */ |
||||||
65 | public function destroy(DestroyTask $request, Task $task) |
||||||
66 | { |
||||||
67 | //el Task $task és equivalent a $task = Task::findOrFail($id) |
||||||
68 | |||||||
69 | $task->delete(); |
||||||
70 | |||||||
71 | return $task; |
||||||
72 | } |
||||||
73 | |||||||
74 | /** |
||||||
75 | * @param UpdateTask $request |
||||||
76 | * @param Task $task |
||||||
77 | * |
||||||
78 | * @return Task |
||||||
79 | */ |
||||||
80 | public function update(UpdateTask $request, Task $task) |
||||||
81 | { |
||||||
82 | $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. ![]() |
|||||||
83 | 'name' => 'required', |
||||||
84 | ]); |
||||||
85 | |||||||
86 | $task->name = $request->name; |
||||||
87 | $task->save(); |
||||||
88 | |||||||
89 | return $task; |
||||||
90 | } |
||||||
91 | } |
||||||
92 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.