Answer the question
In order to leave comments, you need to log in
Laravel 5 model bundle?
Good afternoon.
Framework: Laravel 5.4
Help me understand, the problem is with the model linkage.
There is a model Files and Movies
in the database there are tables files and movies the
table files store files with movies_id:
There is a table movies
As shown in the screenshot, there can be several records in the files table with the same movies_id. How to connect them correctly?
Error while adding entry:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'movies_id' cannot be null
Answer the question
In order to leave comments, you need to log in
Your Movie model is empty. First get the Movie model, then save the related records.
$movie = Movie::find(121);
...
$movie->files()->save($file);
laravel.su/docs/5.0/eloquent
https://laravel.com/docs/5.4/eloquent-relationship...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question