看板 PHP 關於我們 聯絡資訊
假設我要撈出一個區間的產品,例如說 return View::make('product')->with( 'products' => Product::where('id', '>', 10)->take(6)->get() ); 假設 product 有原價跟特價要計算折數秀出 price 100 sell_price 75 view 要帶出 75 (75 折) 我知道可以在 view 下邏輯計算,但還要加上沒有折數時不秀那些 if logic 好像違背了 view 力求簡潔的屬性,不知道是否可以在 model 端做掉計算 那 view 只要下 @if ($discount != 0){{ $discount }} @endif -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 1.34.239.151