本文整理匯總了PHP中app\Order::updating方法的典型用法代碼示例。如果您正苦於以下問題:PHP Order::updating方法的具體用法?PHP Order::updating怎麽用?PHP Order::updating使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Order
的用法示例。
在下文中一共展示了Order::updating方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Order::created(function ($order) {
$status = $order->statusHistory()->create(['status' => 0, 'user_id' => $order->dispatcher_id]);
$status->created_at = $order->created_at;
$status->save();
return true;
});
Order::updating(function ($order) {
if ($order->isDirty('status')) {
$order->statusHistory()->create(['status' => $order->status, 'user_id' => $order->dispatcher_id]);
}
return true;
});
view()->composer('*', function ($view) {
$view->with('user', session('user'));
});
}
示例2: bonus
}
$order->status = static::DEALT;
$order->save();
$transaction && DB::commit();
return true;
}
//優惠其他
public function bonus()
{
$bonus_str = "";
if ($this->bonus_id > 0) {
$bonus_str .= " 紅包抵扣:¥" . ActivityBonus::find($this->bonus_id)->bonus;
}
return $bonus_str;
}
}
Order::creating(function ($order) {
$order->total_money = $order->details_money + $order->expresses_money;
if (intval($order->bonus_id) > 0) {
$bonus = ActivityBonus::find($order->bonus_id);
$order->total_money -= $bonus->bonus;
}
});
Order::updating(function ($order) {
if ($order->isDirty('details_money') || $order->isDirty('expresses_money')) {
if ($order->status != Order::INIT) {
return false;
}
$order->total_money = $order->details_money + $order->expresses_money;
}
});