summaryrefslogtreecommitdiff
path: root/db/migrations/2018_12_27_000000_fix_missing_arrival_dates.php
blob: 4d939bb89b3427f7b2fead82eac14bfe7e7f4afa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php

namespace Engelsystem\Migrations;

use Engelsystem\Database\Migration\Migration;
use Engelsystem\Models\User\State;

class FixMissingArrivalDates extends Migration
{
    /**
     * Run the migration
     */
    public function up()
    {
        $states = State::whereArrived(true)->whereArrivalDate(null)->get();
        foreach ($states as $state) {
            $state->arrival_date = $state->user->personalData->planned_arrival_date;
            $state->save();
        }
    }

    /**
     * Down is not possible and not needed since this is a bugfix.
     */
    public function down()
    {
    }
}