/** * delete data * @return json */ public function delete() { $id = (int) $_POST['id']; DB::beginTransaction(); $rs1 = Type::destroy($id); if (!$rs1) { DB::rollback(); } $attr = DB::select('select * from it_attributes where type_id = ?', [$id]); if ($attr) { $rs2 = Attribute::where('type_id', $id)->delete(); if (!$rs2) { DB::rollback(); } } DB::commit(); if ($rs1) { return response()->json(array('status' => 200, 'message' => 'Deleted Successfully')); } else { return response()->json(array('status' => 400, 'message' => 'Delete Failure')); } }
public function destroy($id) { Type::destroy($id); return back(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Type::destroy($id); return back()->with('info', '删除成功~'); }