order; $profit = 0; foreach ($order->details as $key => $detail) { $profit += $detail->item->profit; } if ($profit > 0) { ProfitLog::addPrfit($profit); } } }