From c60dff095062045b15827ad4d55843ed44caeb6c Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sun, 22 Feb 2026 02:44:05 +0000 Subject: [PATCH] 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 --- app/Http/Controllers/Api/ProjectController.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/ProjectController.php b/app/Http/Controllers/Api/ProjectController.php index 7bf5f6f5b..07131a364 100755 --- a/app/Http/Controllers/Api/ProjectController.php +++ b/app/Http/Controllers/Api/ProjectController.php @@ -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) {