Connect CalDAV todos to DB-Items, finish todo component and add it to pipeline items
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user