success( PlannedTimeReportExport::init( $request->input('projects', Project::all()->pluck('id')->toArray()), )->collection()->all(), )->respond(); } /** * @api {post} /report/planned-time/download Download Planned Time Report * @apiDescription Generate and download a report on planned time for specific projects. * * @apiVersion 4.0.0 * @apiName DownloadPlannedTimeReport * @apiGroup Report * * @apiUse AuthHeader * * @apiHeader {String} Accept Specifies the content type of the response. (Example: `text/csv`) * @apiHeader {String} Authorization Bearer token for API access. (Example: `82|LosbyrFljFDJqUcqMNG6UveCgrclt6OzTrCWdnJBEZ1fee08e6`) * @apiPermission report_generate * @apiPermission report_full_access * * @apiParam {Array} projects Array of project IDs to include in the report. If not provided, all projects will be included. * * @apiParamExample {json} Request Example * { * "projects": [2] * } * * @apiSuccess {String} url URL to the generated report file. * * @apiSuccessExample {json} Response Example * HTTP/1.1 200 OK * { * "url": "/storage/reports/0611766a-2807-4524-9add-2e8be33c3e58/PlannedTime_Report.csv" * } * * @apiUse 400Error * @apiUse ValidationError * @apiUse UnauthorizedError * @apiUse ForbiddenError */ /** * @throws Throwable */ public function download(PlannedTimeReportRequest $request): JsonResponse { $job = new GenerateAndSendReport( PlannedTimeReportExport::init( $request->input('projects', Project::all()->pluck('id')->toArray()), ), $request->user(), ReportHelper::getReportFormat($request), ); app(Dispatcher::class)->dispatchSync($job); return responder()->success(['url' => $job->getPublicPath()])->respond(); } }