优化项目日志

This commit is contained in:
kuaifan
2022-01-13 11:11:29 +08:00
parent 75a12fc6f5
commit cebcc26baf
3 changed files with 44 additions and 10 deletions

View File

@@ -1749,17 +1749,17 @@ class ProjectController extends AbstractController
$project_id = intval(Request::input('project_id'));
$task_id = intval(Request::input('task_id'));
//
$builder = ProjectLog::with(['projectTask:id,name']);
$builder = ProjectLog::select(["*"]);
if ($task_id > 0) {
$task = ProjectTask::userTask($task_id);
$builder->whereTaskId($task->id);
} else {
$project = Project::userProject($project_id);
$builder->whereProjectId($project->id);
$builder->with(['projectTask:id,parent_id,name'])->whereProjectId($project->id);
}
//
$list = $builder->orderByDesc('created_at')->paginate(Base::getPaginate(100, 20));
$list->transform(function (ProjectLog $log) {
$list->transform(function (ProjectLog $log) use ($task_id) {
$timestamp = Carbon::parse($log->created_at)->timestamp;
$log->time = [
'ymd' => date(date("Y", $timestamp) == date("Y", Base::time()) ? "m-d" : "Y-m-d", $timestamp),