作者chan15 (ChaN)
看板PHP
标题[请益] Laravel ORM 问题
时间Tue Aug 20 17:35:45 2013
假设我要捞出一个区间的产品,例如说
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