/** * Remove the specified resource from storage. * * @param int $id * * @return \Illuminate\Http\Response */ public function destroy($id) { $category = Category::with('products')->find($id); if ($category && $category->products->isEmpty()) { if ($category->delete()) { return response()->json(true); } } return response()->json('informatia nu s-a putut sterge', 500); }