pref: 子任务默认起始时间与主任务一致
This commit is contained in:
parent
4d9dd13ffb
commit
e44e77a3a6
@ -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()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user