Skip to content
Advertisement

Eloquent – inserting related models

In this question the accepted answer to saving related models was:

JavaScript

Whenever I try this I get an error:

Column not found: 1054 Unknown column ‘stats’ in ‘field list’

If I add stats to the guarded collection, it of course never comes in.

On my player object I have this:

JavaScript

So how can I have my stats come in, but elqoquent not attempt to use ‘stats’ as a column name in the insert?

Advertisement

Answer

Using the save() method, you can create a new Player object and save it, and then create a new Stat object and save it as a Player related stats():

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement