summaryrefslogtreecommitdiff
path: root/db/migrations/2018_12_27_000000_fix_missing_arrival_dates.php
blob: b932158c995fbb9ac15dcb57120c3542a162bc37 (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
<?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()
    {}
}