public function updated(Order $order)
{
$originals = [];
if ($order->isDirty('order_status')) {
Log::info("order new status :" . $order->order_status . " -- old status :" . $order->getOriginal('order_status'));
}
foreach ($order->getDirty() as $key => $val) {
$originals[$key] = $order->getOriginal($key);
}
Log::info(json_encode([
'changed' => $order->getDirty(),
'originals'=>$originals,
]));
}
Created
May 18, 2020 08:18
-
-
Save slow-is-fast/c62758ef1d552bb9ef179c2689abd92e to your computer and use it in GitHub Desktop.
Laravel Model observer get changed data
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
code in OrderObserve
created by
php artisan make:observe OrderObserve --model=Order