/** * Delete catagory */ public function deleteCatagory($id) { $catagory = Catagory::find($id); Subcatagory::where('catagory_id', $id)->delete(); Product::where('catagory_id', $id)->delete(); if ($catagory->delete()) { return Redirect::back()->with('event', '<p class="alert alert-success"><span class="glyphicon glyphicon-ok"></span> Catagory has been successfully deleted</p>'); } else { return Redirect::back()->with('event', '<p class="alert alert-danger"><span class="glyphicon glyphicon-remove"></span> Something went wrong. Please try after sometime</p>'); } }