Laravel - 购物车。产品被覆盖

时间:2017-02-23 13:58:22

标签: php laravel shopping-cart

我在列表中显示我的产品时出现问题,第一个产品总是被覆盖(只有数量正常)。我不知道什么是错的必须是foreach循环中的一个问题................................... .................................................. .................................................. .............?

    <div class="row">
        <div class="col-sm-6 col-md-6 col-md-offset-3 col-sm-offset-3">
            <ul class="list-group">
                @foreach($products as $product)
                    <li class="list-group-item">
                        <span class="badge">{{ $product['qty'] }}</span>
                        <strong>{{ $product['item']['title'] }}</strong>
                        <span class="label label-success">{{ $product['price'] }}</span>
                        <div class="btn-group">
                            <button type="button" class="btn btn-primary btn-xs dropdown-toogle" data-toggle="dropdown">Action <span class="caret"></span></button>
                            <ul class="dropdown-menu">
                                <li><a href="#">Reduce by 1</a></li>
                                <li><a href="#">Reduce All</a></li>
                            </ul>
                        </div>
                    </li>
                @endforeach
            </ul>
        </div>
    </div>


when I do dd($products), I get just one Item in the array as you can see below:

`

array:1 [▼
  "" => array:3 [▼
    "qty" => 2
    "price" => 60
    "item" => Product {#170 ▼
      #fillable: array:4 [▶]
      #connection: null
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:7 [▶]
      #original: array:7 [▶]
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #events: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▶]
    }
  ]
]

`

0 个答案:

没有答案