So I have a pretty basic CRUD application with 2 models. Website and Category. Website consists of a name, a link and a category_id (which is a reference to the name of Category). Category consists of a name (which is the primary key) and an icon. When I want to update the Category model, I send my API a request with the new name, the original name and the icon. When I try to save the model, I get an error:
"SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`startpage`.`website`, CONSTRAINT `website_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`name`)) (SQL: update `categories` set `name` = Search Engines where `name` = Search Egnines)"
It is obvious that the problem lies in trying to update an attribute that is used to define relations between the tables. My question therefore is, is there a way for me to update the attribute and simultaneously update all references to it, so the relations stay intact?
Thanks in advance!