Can you take a look at my recent post? I have an issue I'm trying to fix ASAP
Aug 3, 2019
5
Level 5
How to delete individual data from session
Hi, i have data in session in below format. i want to delete the data based on id. So how my method should be in order delete data according id.
This is data in session
[
{
id: 5,
name: "Prof. Iliana Mohr",
description: "Autem sequi esse laudantium ut ut explicabo enim. Corporis cupiditate dolorum et ratione sequi architecto. Vitae enim ex hic nihil.",
category_id: 2,
price: 207,
image: "http://loremflickr.com/400/300?random=99",
created_at: "2019-07-16 10:12:27",
updated_at: "2019-07-16 10:12:27",
qty: 1
},
{
id: 2,
name: "Marlene Reichert",
description: "Debitis asperiores sed sit assumenda unde quo natus. Consequatur est labore tenetur quae. Eius distinctio ea omnis aspernatur porro earum quae.",
category_id: 3,
price: 76,
image: "http://loremflickr.com/400/300?random=71",
created_at: "2019-07-16 10:12:27",
updated_at: "2019-07-16 10:12:27",
qty: 1
},
{
id: 1,
name: "Keyshawn McDermott Sr.",
description: "Error aut quia id dolorem est aut doloribus nesciunt. Quod nihil tenetur ea id voluptas molestias id. Debitis amet dolor est fugiat sed autem.",
category_id: 1,
price: 59,
image: "http://loremflickr.com/400/300?random=36",
created_at: "2019-07-16 10:12:27",
updated_at: "2019-07-16 10:12:27",
qty: 1
}
]
for example when user click the delete button in view, i want to delete record with id 5.
method:
public function deleteProduct(Request $request){
$id = $request->productId;// this gives id that is submitted from form/link
$request->forget($id);// this delete all records
//i want to delete only one record which user wants/clicked.
}
Please or to participate in this conversation.