tpaksu /
laravel-todobar
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace TPaksu\TodoBar\Controllers; |
||||
| 4 | |||||
| 5 | use App\Http\Controllers\Controller; |
||||
|
0 ignored issues
–
show
|
|||||
| 6 | use Illuminate\Http\Request; |
||||
|
0 ignored issues
–
show
The type
Illuminate\Http\Request was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 7 | use TPaksu\TodoBar\Storage\DataStorageInterface; |
||||
| 8 | |||||
| 9 | class TodoBarTasks extends Controller |
||||
| 10 | { |
||||
| 11 | protected $storage; |
||||
| 12 | |||||
| 13 | public function __construct(DataStorageInterface $storage) |
||||
| 14 | { |
||||
| 15 | $this->storage = $storage; |
||||
| 16 | } |
||||
| 17 | /** |
||||
| 18 | * Display a listing of the resource. |
||||
| 19 | * |
||||
| 20 | * @return \Illuminate\Http\Response |
||||
|
0 ignored issues
–
show
The type
Illuminate\Http\Response was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 21 | */ |
||||
| 22 | public function index(Request $request, $project_id) |
||||
| 23 | { |
||||
| 24 | if ($project_id >= 0) { |
||||
| 25 | $project = $this->storage->find($project_id) ?? null; |
||||
| 26 | if ($project) { |
||||
| 27 | return response()->json([ |
||||
|
0 ignored issues
–
show
The function
response was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 28 | "status" => "success", |
||||
| 29 | "project" => $project, |
||||
| 30 | "html" => view()->make('laravel-todobar::partials.tasks', ["tasks" => $project->tasks, "project_id" => $project_id])->render(), |
||||
|
0 ignored issues
–
show
The function
view was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 31 | ], 200); |
||||
| 32 | } |
||||
| 33 | return response()->json(["status" => "error", "error" => "Sorry, we can't find the project with that ID."]); |
||||
| 34 | } else { |
||||
| 35 | return response()->json([ |
||||
| 36 | "status" => "success", |
||||
| 37 | "project" => null, |
||||
| 38 | "html" => view()->make('laravel-todobar::partials.tasks')->render(), |
||||
| 39 | ], 200); |
||||
| 40 | } |
||||
| 41 | } |
||||
| 42 | |||||
| 43 | /** |
||||
| 44 | * Store a newly created resource in storage. |
||||
| 45 | * |
||||
| 46 | * @param \Illuminate\Http\Request $request |
||||
| 47 | * @return \Illuminate\Http\Response |
||||
| 48 | */ |
||||
| 49 | public function store(Request $request, $project_id) |
||||
| 50 | { |
||||
| 51 | $request->validate([ |
||||
| 52 | "content" => "required|string|filled", |
||||
| 53 | ]); |
||||
| 54 | |||||
| 55 | $project = $this->storage->find($project_id); |
||||
| 56 | |||||
| 57 | if ($project) { |
||||
| 58 | $project->tasks[] = (object)[ |
||||
| 59 | "content" => $request->content, |
||||
| 60 | "completed" => 0, |
||||
| 61 | ]; |
||||
| 62 | $this->storage->update($project_id, $project); |
||||
| 63 | return response()->json(["status" => "success"], 200); |
||||
|
0 ignored issues
–
show
The function
response was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 64 | } else { |
||||
| 65 | return response()->json(["status" => "error", "error" => "We couldn't find the project that you wanted to add that task."], 200); |
||||
| 66 | } |
||||
| 67 | } |
||||
| 68 | |||||
| 69 | /** |
||||
| 70 | * Update the specified resource in storage. |
||||
| 71 | * |
||||
| 72 | * @param \Illuminate\Http\Request $request |
||||
| 73 | * @param int $id |
||||
| 74 | * @return \Illuminate\Http\Response |
||||
| 75 | */ |
||||
| 76 | public function update(Request $request, $project_id, $task_id) |
||||
| 77 | { |
||||
| 78 | if ($request->has("status")) { |
||||
| 79 | $request->validate([ |
||||
| 80 | "status" => "required|boolean" |
||||
| 81 | ]); |
||||
| 82 | $update = "completed"; |
||||
| 83 | $update_key = "status"; |
||||
| 84 | } else { |
||||
| 85 | $request->validate([ |
||||
| 86 | "content" => "required|string|filled", |
||||
| 87 | ]); |
||||
| 88 | $update = "content"; |
||||
| 89 | $update_key = "content"; |
||||
| 90 | } |
||||
| 91 | |||||
| 92 | $project = $this->storage->find($project_id); |
||||
| 93 | |||||
| 94 | if ($project) { |
||||
| 95 | if (isset($project->tasks[$task_id])) { |
||||
| 96 | |||||
| 97 | $project->tasks[$task_id]->{$update} = $request->get($update_key); |
||||
| 98 | |||||
| 99 | $this->storage->update($project_id, $project); |
||||
| 100 | return response()->json(["status" => "success"], 200); |
||||
|
0 ignored issues
–
show
The function
response was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 101 | } else { |
||||
| 102 | return response()->json(["status" => "error", "error" => "We couldn't find the task that you wanted to update."], 200); |
||||
| 103 | } |
||||
| 104 | } else { |
||||
| 105 | return response()->json(["status" => "error", "error" => "We couldn't find the project that you wanted to add that task."], 200); |
||||
| 106 | } |
||||
| 107 | } |
||||
| 108 | |||||
| 109 | /** |
||||
| 110 | * Remove the specified resource from storage. |
||||
| 111 | * |
||||
| 112 | * @param int $id |
||||
| 113 | * @return \Illuminate\Http\Response |
||||
| 114 | */ |
||||
| 115 | public function destroy($project_id, $task_id) |
||||
| 116 | { |
||||
| 117 | $project = $this->storage->find($project_id); |
||||
| 118 | |||||
| 119 | if ($project) { |
||||
| 120 | if (isset($project->tasks[$task_id])) { |
||||
| 121 | unset($project->tasks[$task_id]); |
||||
| 122 | $project->tasks = array_values($project->tasks); |
||||
| 123 | $this->storage->update($project_id, $project); |
||||
| 124 | return response()->json(["status" => "success"], 200); |
||||
|
0 ignored issues
–
show
The function
response was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 125 | } else { |
||||
| 126 | return response()->json(["status" => "error", "error" => "We couldn't find the task that you wanted to update."], 200); |
||||
| 127 | } |
||||
| 128 | } else { |
||||
| 129 | return response()->json(["status" => "error", "error" => "We couldn't find the project that you wanted to add that task."], 200); |
||||
| 130 | } |
||||
| 131 | } |
||||
| 132 | } |
||||
| 133 |
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