doudan4834
2019-07-13 14:19
浏览 87
已采纳

Laravel - 选择特定付款方式的总和价格

I'm currently working on some project that needs price summing for each method of payment selected. I did total price sum but I need split sum for every method of payment that is selected during creation

So this is code for sum total price in my home blade

<tfoot>
  <tr>
    <th>UKUPAN IZNOS:&nbsp;&nbsp;{{ Auth::user()->posts->sum('cijena') }}&euro;</th>
  </tr>
</tfoot>

And this is my code for choosing method of payment during creation

<div class="column">
  <label for="placanje">Placanje:</label>
  </br>
  <select 
    class="form-control"
    id="soflow"
    name="placanje"
  >
    <option value="Kartica">Kartica</option>
    <option value="Gotovina">Gotovina</option>
    <option value="Virman">Virman</option>
  </select>
</div>
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dougong7850 2019-07-13 14:28
    已采纳

    So you probably need to display them separately, you can do it like this:

    Auth::user()->posts->where('placanje', 'Kartica')->sum('cijena');
    

    and do the same for each option.

    打赏 评论

相关推荐 更多相似问题