如何在值为空时禁用输入 laravel livewire

how to disable input when the value is empty laravel livewire

我正在使用 livewire,laravel 7。下面是代码。如何在值为空时确保输入是只读的?

 <div class="form-row">
                    @foreach($serviceOrder as $o)
                        <div class="col-md-5 mb-3">
                            <label class="form-control-label" >Service {{ $loop->iteration }} </label>
                            <input type="text"  wire:model="serviceOrder.{{ $loop->index }}.serv.serviceName" class="form-control " readonly>
                           
                        </div>
                        <input type="hidden"  wire:model="serviceOrder.{{ $loop->index }}.serv.servicePrice" class="form-control col-sm-1 mb-3" readonly>
                       
                        <div class="col-md-3 mb-3">
                            <label class="form-control-label" >Weight/Size</label>
                            <input type="text" name="" value=""  wire:model="serviceOrder.{{ $loop->index }}.weightsize"  class="form-control">
                        </div>
                        
                        <div class="col-md-3 mb-3">
                            
                            <label class="form-control-label" >Quantity*opt</label>
                                <input type="text" name="" value="" wire:model="serviceOrder.{{ $loop->index }}.quantity"  class="form-control" @if(!$quantity)  readonly @endif >
                        </div>
                    @endforeach
                    </div>

我关注的是这部分

 <div class="col-md-3 mb-3"> 
                        <label class="form-control-label" >Quantity*opt</label>
                            <input type="text" name="" value="" wire:model="serviceOrder.{{ $loop->index }}.quantity"  class="form-control" @if(!$quantity)  readonly @endif >
                    </div>

对于没有值的输入,应该是" ",它是一个可以为空的数量变量

尝试在元素中添加此检查:

<input type="text" wire:model="serviceOrder.{{ $loop->index }}.quantity"  class="form-control" @if(!$serviceOrder[$loop->index]['quantity']) readonly @endif>