I want to add or minus the number of medicine stock that is being stored. Are there better ways to do better than mine.
@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
This is the Form that I included
@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
And how do I change the value of the stored medicine_qty to the new one that is being added or minus
你可以这样做。
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.