<?php
/**
 * Created by PhpStorm.
 * User: mead
 * Date: 2018/7/12
 * Time: 上午10:17
 */

namespace App\Observers;

use App\Good;
use App\Trace;

class TraceObserver
{
    public function updated(Trace $trace)
    {
        $gid = $trace->gid;
        $group = Good::where('id', $gid)->value('group');
        if ($group) {
            if (($trace->id % $group) == 1) {
                Trace::where('gid', $gid)->where('group', $trace->group)->update(['dealer_id' => $trace->dealer_id]);
            }
        }
    }
}