in there i have a data, i want to add a delete data where i selected. here my code :
public function postDeleteall(){
$id = Request::get('id');
if($id ==''){
Session::flash('delete', 'select first !');
return redirect()->back();
}else{
foreach ($id as $q) {
$qwery = DB::table('log_patrols')->where('id',$q)->get();
foreach ($qwery as $a) {
DB::table('log_patrols')->where('id',$a->id)->delete();
$row =DB::table('log_patrol_details')->where('id_log_patrols',$a->id)->get();
foreach ($row as $qwe) {
@unlink(public_path("uploads/".$qwe->photo1));
@unlink(public_path("uploads/".$qwe->photo2));
@unlink(public_path("uploads/".$qwe->photo3));
}
$rows = DB::table('log_patrol_details')->where('id_log_patrols',$q)->delete();
Session::flash('delete', 'success');
return redirect()->back();
}
}
}
}
when i try to print the data $id
its want to get the data id where i select, but after i try to make the code its won't work like what i want. and its only delete 1 data where i selected. what should i do ? and what code need i change in my skript ?
thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire