我要增加或减少正在存储的药品库存数量。有比我更好的方法来做得更好。
@if(count($medicines) > 0)
@foreach($medicines as $medicine)
@if($medicine->medicine_details==="Non-Prescribed")
<tr>
<th scope="row">{{$medicine->medicine_name}}</th>
<th scope="row">{{$medicine->medicine_details}}</th>
<td>{{$medicine->medicine_qty}}
@include('forms.incrementMed')
</td>
</tbody>
@endif
@endforeach
@endif
这是我包含的表格
@if( $medicine->medicine_qty < 100)
<input style="width: 50px;" class="box" type="number" id="qty" value="qty">
<button type="submit" class="btn btn-secondary" data-dismiss="modal" name="addMed" id="addMed" >Add</button>
@elseif( $medicine->medicine_qty >= 100)
<input style="width: 50px;" class="box" type="number" id="qty" value="qty">
<button type="submit" class="btn btn-secondary" data-dismiss="modal" name="minusMed" id="minusMed" >Minus</button>
@endif
如何将存储的medicine_qty的值更改为要添加或减去的新值
答案 0 :(得分:0)
您可以这样做。
<button type="submit" class="btn btn-secondary" data-dismiss="modal" name="{{$medicine->medicine_qty < 100? addMed :'minusMed' }}" id="{{$medicine->medicine_qty < 100? addMed :'minusMed' }}" >{{$medicine->medicine_qty < 100? 'ADD':'Minus' }}</button>