feat(api): add with_extend param to task/lists endpoint

Supports optional `with_extend` query parameter (comma-separated).
When `project_name` or `column_name` is included, the API returns
these fields inline with each task via eager loading.

Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
kuaifan 2026-02-22 02:44:05 +00:00
parent f2d49ee104
commit c60dff0950

View File

@ -1051,8 +1051,16 @@ class ProjectController extends AbstractController
$owner = is_numeric($owner) ? intval($owner) : null;
$keys = is_array($keys) ? $keys : [];
$sorts = is_array($sorts) ? $sorts : [];
$with_extend = array_filter(explode(',', Request::input('with_extend', '')));
$builder = ProjectTask::with(['taskUser', 'taskTag']);
$withs = ['taskUser', 'taskTag'];
if (in_array('project_name', $with_extend)) {
$withs[] = 'project:id,name';
}
if (in_array('column_name', $with_extend)) {
$withs[] = 'projectColumn:id,name';
}
$builder = ProjectTask::with($withs);
//
if ($keys['name']) {
if (Base::isNumber($keys['name'])) {
@ -1247,6 +1255,14 @@ class ProjectController extends AbstractController
unset($item['_sub_num']);
unset($item['_sub_complete']);
unset($item['_percent']);
if (in_array('project_name', $with_extend)) {
$item['project_name'] = $item['project']['name'] ?? '';
unset($item['project']);
}
if (in_array('column_name', $with_extend)) {
$item['column_name'] = $item['project_column']['name'] ?? '';
unset($item['project_column']);
}
}
//
if ($list->currentPage() === 1) {