Hello, What if we have a relation in the products table to some category? Should we add in our migration some onDelete, onUpdate events?
I got an error like this:
{"message": "SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`laravel_api`.`products`, CONSTRAINT `products_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`)) (Connection: mysql, SQL: delete from `categories` where `id` = 2)"}
It depends on what you want to do on that update/delete events. One of the ways is to have ->cascadeOnDelete() at the end, so it would delete the related records.
Hello, What if we have a relation in the products table to some category? Should we add in our migration some onDelete, onUpdate events? I got an error like this:
It depends on what you want to do on that update/delete events. One of the ways is to have
->cascadeOnDelete()
at the end, so it would delete the related records.those constant from symphony i check the documentation in laravel but they are not mentionned there .
I have a question one of you recommendations is not to pass " $request->all() " in order to create because is not unsafe ?
Correct, here's an article about it: //post/laravel-request-all-security-issue
thank you