Perhaps you don't need a pivot table using has many it is more like a post with articles. Also I believe there is a laracast on that very subject you are trying to do.
jimgwhit said:
Perhaps you don't need a pivot table using has many it is more like a post with articles. Also I believe there is a laracast on that very subject you are trying to do.
I have already watched some of laracast's videos and I did the exact same thing as shown in the video... I'm not sure what you mean
See this ==https://scotch.io/tutorials/a-guide-to-using-eloquent-orm-in-laravel. Also. http://laravel.io/forum/search?query=hasmany. http://laravel.io/forum/search?query=one+to+many and. http://laravel.com/docs/5.0/eloquent#one-to-many
First off in the first code you're referencing you are outputting a column "user_id" from a find query, not the user method you have defined.
Secondly do you have any records under the ID 1 in both the users and history tables?
lnenad said:
First off in the first code you're referencing you are outputting a column "user_id" from a find query, not the user method you have defined.
Secondly do you have any records under the ID 1 in both the users and history tables?
That was one of the things I did wrong. The other thing was that I created a history row the wrong way. I did this:
$history = History::create(["user_id" => User::find(1), "video_name" => "example"]);
insted of:
$history = History::create(["user_id" => 1, "video_name" => "example"]);
BTW, how come the first row didn't show any errors since I was assigning object to a column?
I would also like to thank everyone for their help.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community