W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
有時(shí)候訂購(gòu)行為會(huì)跟「數(shù)量」有關(guān)。例如,你的應(yīng)用程序可能會(huì)依照帳號(hào)的用戶人數(shù),每人每月收取 $10 元。你可以使用 increment 和 decrement 方法簡(jiǎn)單的調(diào)整訂購(gòu)數(shù)量:
$user = User::find(1);
$user->subscription()->increment();
// Add five to the subscription's current quantity...
$user->subscription()->increment(5);
$user->subscription()->decrement();
// Subtract five to the subscription's current quantity...
$user->subscription()->decrement(5);
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: