Answer the question
In order to leave comments, you need to log in
Delete collection object?
I have a collection of objects that I have tried:
$my_collection->where('bar_code', $product->bar_code)->delete();
$my_collection->where('bar_code', $product->bar_code)->destroy();
$my_collection->where('bar_code', $product->bar_code)->first()->delete();
$my_collection->where('bar_code', $product->bar_code)->first()->destroy();
unset($my_collection->where('bar_code', $product->bar_code)->first());
$collection = $my_collection->keyBy('bar_code');
$collection->forget($product->bar_code);
Collection {#307 ▼
#items: array:1 [▼
0 => array:4 [▼
"name" => "Organic human-resource analyzer"
"price" => "958.1"
"bar_code" => "14446831"
"quantity" => "1"
]
]
}
Answer the question
In order to leave comments, you need to log in
$collection = session('cartItems')->keyBy('bar_code');
$collection->forget($product->bar_code);
session(['cartItems' => $collection]);
Why don't you try to find it in the dock? Why are you making your answers as a solution?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question