Skip to content

Commit

Permalink
pref: 子任务默认起始时间与主任务一致
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Jan 6, 2022
1 parent 4d9dd13 commit e44e77a
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use App\Models\ProjectTask;
use Illuminate\Database\Migrations\Migration;

class ProjectTasksUpdateSubtaskTime extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
ProjectTask::where('parent_id', '>', 0)
->whereNull('end_at')
->chunkById(100, function ($lists) {
/** @var ProjectTask $task */
foreach ($lists as $task) {
$parent = ProjectTask::whereNotNull('end_at')->find($task->parent_id);
if ($parent) {
$task->start_at = $parent->start_at;
$task->end_at = $parent->end_at;
$task->save();
}
}
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

0 comments on commit e44e77a

Please sign in to comment.