/** * Approves a CERF by deleting all other pending CERFs for the same event. * * @param $id * @return \Illuminate\Http\RedirectResponse */ public function approve($id) { $cerf = Cerf::find($id); $cerf->update(['approved' => true]); $otherCerfs = Cerf::where('event_id', $cerf->event_id)->where('approved', false)->get(); foreach ($otherCerfs as $cerf) { // See comments in CerfsController@destroy. DB::statement('delete from cerfs where id=' . $cerf->id); DB::statement('delete from events_assigned_tags where cerf_id=' . $cerf->id); } return redirect()->action('CerfsController@overview'); }