Я пытаюсь получить данные из нескольких строк в одном вызове по их идентификатору, но я получаю эту ошибку каждый раз, когда отправляю форму. 'Свойство [владелец] не существует в этом экземпляре коллекции.' Можете ли вы сказать мне, что я делаю неправильно?
Мой контроллер
public function delivery(Request $request) {
$iid = $request->inv_id;
$item = DB::table('inventory')
->join('products', 'products.id', '=', 'inventory.product_id')
->whereIn('inventory.id', $iid)
->select('products.*' , 'inventory.id as id1')
->get();
//Check if user owns the items
if ($item->owner != Auth::user()->id)
return back()->with('error', 'Nu detii acest obiect.');
//Check if item is not sold
if ($item->sold == 1)
return back()->with('error', 'Din pacate acest obiect este vandut.');
//Check if the item is not put in the marketplace
if ($item->on_market == 1)
return back()->with('error', 'Acest obiect este plasat la vanzare pe market.');
// Set Inventory Item redemeed to 1
Inventory::whereIn('id', $iid)
->update(['redeemed' => 1]);
return redirect('/inventory')->with('success', 'Success');
}
Мой клинок:
<input type="hidden" name="inv_id[]" value="{{$product->id1}}">
dd ($ item) Вывод
Collection {#679 ▼
#items: array:3 [▼
0 => {#677 ▼
+"id": 339
+"product_id": 13
+"game_key": null
+"owner": "6"
+"redeemed": 0
+"visible": 1
+"delivered": 0
+"sold": 0
+"on_market": 0
+"item_nr": "8062731872"
+"created_at": "2020-02-07 17:13:52"
+"updated_at": "2020-02-07 17:13:52"
+"id1": 339
}
1 => {#674 ▶}
2 => {#664 ▶}
]
}