Connect CalDAV todos to DB-Items, finish todo component and add it to pipeline items

This commit is contained in:
2026-02-24 16:15:21 +01:00
parent 7e2094847f
commit 823cd6391d
27 changed files with 605 additions and 205 deletions
+30 -7
View File
@@ -16,15 +16,38 @@ class PipelineController extends Controller
{
public function index()
{
$lanes = PipelineLane::with(['items' => function ($q) {
$q->withCount(['notes' => function ($query) {
$query->where('notable_type', 'App\Models\PipelineItem');
}])->orderBy('position');
}])->orderBy('position')->get();
$lanes = PipelineLane::with(['items' => function ($query) {
$query
->withCount(['notes' => function ($query) {
$query->where('notable_type', 'App\Models\PipelineItem');
}])
->withCount(['todos' => function ($query) {
$query->where('todoable_type', 'App\Models\PipelineItem')
->whereNotIn('status', ['completed', 'COMPLETED']);
}])
->with(['todos' => function ($query) {
$query->where('todoable_type', 'App\Models\PipelineItem')->orderBy('due_date', 'asc');
}])
->orderBy('position')
;
}])
->orderBy('position')
->get();
return $lanes->map(function ($lane) {
return ApiDataTransformer::snakeToCamel($lane->toArray());
$lanesArray = $lanes->map(function ($lane) {
$laneArray = $lane->toArray();
// Process items to add latest_todo_due_date and remove todos array
$laneArray['items'] = collect($laneArray['items'])->map(function ($item) {
$item['next_todo_due_date'] = $item['todos'][0]['due_date'] ?? null;
unset($item['todos']); // Remove the todos array
return $item;
})->toArray();
return $laneArray;
});
return ApiDataTransformer::snakeToCamel($lanesArray->toArray());
}
public function show()