I am getting this error whenever I try to delete and element in the array. It only work when I delete everything. But I want to delete one by one. this is delete function
public function delete($id){
$user_id = auth() ->user()->id;
$card = travel_plan::all()->where('travel_id', $user_id);
foreach($card as $cardId){
$cardd = $cardId;
} //->where('city_name', $uo)->first();
$cardd->delete();
return redirect('/home')->with('success', 'Post Removed');
}
this is my delete button
{!!Form::open(['action'=>['TravelPlanController@delete','id' =>$cardd[]],'method'=>'POST','class'=>''])!!}
this is how I retrieved the id
$cardd = array();
$card = travel_plan::all()->where('travel_id', $user_id);
foreach($card as $cardId){
$cardd [] = $cardId ->id;
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire