/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { if (States::isProtected($id)) { return $this->error("This item is protected"); } if (sizeof(States::all()) <= 2) { return $this->error("Do you really want to delete all States? In which state are you?!"); } if (Items::hasStatus($id) || Persons::hasStatus($id)) { return $this->error("Do you really want to delete all States? In which state are you?!"); } $data = States::find($id); if ($data) { $data->delete(); return $this->success($data); } else { return $this->error("Item doesn't exist"); } }