首页 > 解决方案 > 是否可以在laravel中的Array ['在此处添加变量']中分配变量

问题描述

是否可以在数组 [' $addhere '] 内分配一个变量?我在变量中分配了一个值,我想把它放在 []

这是变量

@php
    $order_id=$orderItem->id;
@endphp

我想把它放在这里,

{{$partialDeliveries[$order_id]->stock_in_qty}}

错误响应

在此处输入图像描述

刀片中的表

<table class="table table-striped m-b-none" id="orders"  >
                <thead>
                <tr>
                    <th width="">Product Code</th>
                    <th>Product Name</th>
                    <th>Quantity</th>
                    <th>Delivery Date</th>
                    <th>Notes</th>
                </tr>
                </thead>
                <tbody>
                    @foreach($order->orderItems as $orderItem)
                    @php
                        $order_id=$orderItem->id;
                    @endphp
                    <tr>
                        <td>{{ $orderItem->product_code }} {{$order_id}}</td>
                        <td>{{ $orderItem->product_name }} {{$partialDeliveries[$order_id]->stock_in_qty}}</td>
                        {{-- <td> {{$orderItem->quantity}}</td> --}}
                        <td><input type="number" name="stock_in_qty[]" id="stock_in_qty_{{$orderItem->id}}" class="form-control stock_in_qty" min="1" value="{{$orderItem->quantity}}" data-max="{{$orderItem->quantity}}" onkeyup="check(this);"/></td>
                         <script type="text/javascript">
                            var $orderItem_id = {{$orderItem->id}};
                            $('#stock_in_qty_'+$orderItem_id).on('mouseup keyup', function () {
                                $(this).val(Math.min({{$orderItem->quantity}}, Math.max(1, $(this).val())));
                            });
                        </script>
                        <td> {{ Form::date('delivery_date[]',today(), ['class' => 'form-control date', 'style' => 'width:200px;','required']) }}</td>
                        <td>{!! Form::text('delivery_note[]', null, ['class'=>'form-control']) !!}
                        @if ($errors->has('delivery_note'))<span class="help-block"><strong>{{ $errors->first('delivery_note') }}</strong></span>@endif
                        </td>          
                    </tr>
                    {!! Form::hidden('product_id[]', $orderItem->product_id) !!}
                    {!! Form::hidden('stock_in_qty[]', $orderItem->quantity) !!}
                    {!! Form::hidden('order_id[]', $order->id) !!}
                    {!! Form::hidden('order_item_id[]', $orderItem->id ) !!}
                    {!! Form::hidden('company_id[]', $order->company->id) !!}
                    {!! Form::hidden('stock_out_qty[]',null) !!}
                    {!! Form::hidden('transfer_to[]', null) !!}
                    {!! Form::hidden('user_id[]',auth()->user()->id ) !!}
                    @endforeach
                </tbody>
            </table>

标签: arrayslaravel

解决方案


推荐阅读