/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $announcements = Announcement::find($id); $announcements->delete(); Session::flash('message', 'You have successfully deleted announcement'); return Redirect::to('dashboard/admin/announcements'); }
/** * Responds to requests to GET /announcement/delete/{id?} */ public function getDelete($id) { # Get the announcement to be deleted $announcement = \App\Announcement::find($id); if (is_null($announcement)) { \Session::flash('message', 'Announcement not found.'); return redirect('/announcements'); } # Then delete the announcement $announcement->delete(); # Done \Session::flash('message', $announcement->title . ' was deleted.'); return redirect('/announcements'); }
public function destroy(Request $request) { $model = Announcement::find($request->id); if (empty($model)) { Flash::error('Impossible de supprimer cette annonce.'); return Redirect::back(); } $model->delete(); Flash::success('L\'annonce a bien été supprimée.'); return redirect('announcements/list'); }