1 | <?php |
||||||
2 | |||||||
3 | namespace App\Http\Controllers; |
||||||
4 | |||||||
5 | use App\Http\Requests\CompleteTask; |
||||||
6 | use App\Http\Requests\DestroyTask; |
||||||
7 | use App\Http\Requests\ListTask; |
||||||
8 | use App\Http\Requests\ShowTask; |
||||||
9 | use App\Http\Requests\StoreTask; |
||||||
10 | use App\Http\Requests\UpdateTask; |
||||||
11 | use App\Task; |
||||||
12 | |||||||
13 | class ApiTaskController extends Controller |
||||||
14 | { |
||||||
15 | public function index(ListTask $request) |
||||||
0 ignored issues
–
show
|
|||||||
16 | { |
||||||
17 | return Task::all(); |
||||||
18 | } |
||||||
19 | |||||||
20 | // Injeccció de depèndències |
||||||
21 | public function store(StoreTask $request) |
||||||
22 | { |
||||||
23 | $task = Task::create([ |
||||||
24 | 'name' => $request->name, |
||||||
25 | 'description' => $request->description, |
||||||
26 | 'user_id' => $request->user_id, |
||||||
27 | 'completed' => false, |
||||||
28 | ]); |
||||||
29 | |||||||
30 | return $task; |
||||||
31 | } |
||||||
32 | |||||||
33 | public function destroy(DestroyTask $request, Task $task) |
||||||
34 | { |
||||||
35 | $task->delete(); |
||||||
36 | |||||||
37 | return $task; |
||||||
38 | } |
||||||
39 | |||||||
40 | public function update(UpdateTask $request, Task $task) |
||||||
41 | { |
||||||
42 | $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. ![]() |
|||||||
43 | 'name' => 'required', |
||||||
44 | ]); |
||||||
45 | $task->name = $request->name; |
||||||
46 | $task->save(); |
||||||
47 | |||||||
48 | return $task; |
||||||
49 | } |
||||||
50 | |||||||
51 | public function complete(CompleteTask $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. ![]() |
|||||||
52 | { |
||||||
53 | $task->update(['completed' => $task->completed ? false : true]); |
||||||
54 | |||||||
55 | return $task; |
||||||
56 | } |
||||||
57 | |||||||
58 | 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. ![]() |
|||||||
59 | { |
||||||
60 | return $task; |
||||||
61 | } |
||||||
62 | } |
||||||
63 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.