I can’t delete a category because it is a foreign key in the items table. How can I do it? How can I make a deletion in category and make $category_id null in the items table?
I tried making a delete function but it sends an error saying it can’t because it is a foreign key.
2
Answers
Create a migration to allow the field
category_id
to have null value and to default to null when the referenced category is deleted by setting onDelete null on foreign keyYou can also read from here
Official Docs