You are using insert() method of the Query Builder, instead of save() method of the Model. Insert is a basic insert statement and it does not know about relations, timestamps or anything else that is specific to the Eloquent Model. So simply use this code:
Author::find(1)->posts()->save(
new Post(array('title' => 'My first post ever', 'body' => 'This is going to be the best Eloquent lesson!'))
);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community