1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace TPaksu\TodoBar\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Http\Controllers\Controller; |
|
|
|
|
6
|
|
|
use Illuminate\Http\Request; |
|
|
|
|
7
|
|
|
use TPaksu\TodoBar\Storage\DataStorageInterface; |
8
|
|
|
|
9
|
|
|
class TodoBarProjects extends Controller |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
protected $storage; |
13
|
|
|
|
14
|
|
|
public function __construct(DataStorageInterface $storage) |
15
|
|
|
{ |
16
|
|
|
$this->storage = $storage; |
17
|
|
|
} |
18
|
|
|
/** |
19
|
|
|
* Display a listing of the resource. |
20
|
|
|
* |
21
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
22
|
|
|
*/ |
23
|
|
|
public function index() |
24
|
|
|
{ |
25
|
|
|
$data = collect($this->storage->all())->pluck("name"); |
|
|
|
|
26
|
|
|
return response()->json(["status" => "success", "data" => $data], 200); |
|
|
|
|
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Store a newly created resource in storage. |
31
|
|
|
* |
32
|
|
|
* @param \Illuminate\Http\Request $request |
33
|
|
|
* @return \Illuminate\Http\Response |
34
|
|
|
*/ |
35
|
|
|
public function store(Request $request) |
36
|
|
|
{ |
37
|
|
|
$new_id = $this->storage->insert([ |
38
|
|
|
"name" => $request->name, |
39
|
|
|
"tasks" => [] |
40
|
|
|
]); |
41
|
|
|
return response()->json(["status" => "success", "id" => $new_id, "name" => $request->name], 200); |
|
|
|
|
42
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Display the specified resource. |
47
|
|
|
* |
48
|
|
|
* @param int $id |
49
|
|
|
* @return \Illuminate\Http\Response |
50
|
|
|
*/ |
51
|
|
|
public function show($id) |
52
|
|
|
{ |
53
|
|
|
$tasks = $this->storage->find($id) ?? []; |
54
|
|
|
return response()->json(["status" => "success", "tasks" => $tasks], 200); |
|
|
|
|
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Update the specified resource in storage. |
59
|
|
|
* |
60
|
|
|
* @param \Illuminate\Http\Request $request |
61
|
|
|
* @param int $id |
62
|
|
|
* @return \Illuminate\Http\Response |
63
|
|
|
*/ |
64
|
|
|
public function update(Request $request, $id) |
65
|
|
|
{ |
66
|
|
|
$this->storage->update($id, [ |
67
|
|
|
"name" => $request->name, |
68
|
|
|
]); |
69
|
|
|
return response()->json(["status" => "success", "id" => $id, "name" => $request->name], 200); |
|
|
|
|
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Remove the specified resource from storage. |
74
|
|
|
* |
75
|
|
|
* @param int $id |
76
|
|
|
* @return \Illuminate\Http\Response |
77
|
|
|
*/ |
78
|
|
|
public function destroy($id) |
79
|
|
|
{ |
80
|
|
|
$this->storage->delete($id); |
81
|
|
|
return response()->json(["status" => "success"], 200); |
|
|
|
|
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
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