Answer the question
In order to leave comments, you need to log in
How to properly create relationships between models and implement a function?
Information system analysis of art and those... The
question is this:
There is a user model, books, and reviews.
It is necessary to correctly register the function of creating a review in the ReviewController ( app/Http/Controllers/ ) so that it is automatically linked to the user who created the review and to the book for which the review was written.
Perhaps the relationships between the models are incorrectly specified.
The database has all the required columns.
There are some crooked attempts to implement this function, you will see all this in the controller itself.
At the moment this error is thrown:
Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`bookshelf`.`reviews`, CONSTRAINT `book_review_book_id_foreign` FOREIGN KEY (`book_id`) REFERENCES `books` (`id`) ON DELETE CASCADE) (SQL: insert into `reviews` (`body`, `user_id`, `updated_at`, `created_at`) values (SOME TEXT SOME TEXT SOME TEXT SOME TEXT , 1, 2016-06-18 03:37:36, 2016-06-18 03:37:36)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question