Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLSTATE[HY000]: General error: 1364 Field 'xxx_id' doesn't have a default value #7

Open
hugeps opened this issue Dec 30, 2017 · 1 comment

Comments

@hugeps
Copy link

hugeps commented Dec 30, 2017

Basically looks like the foreign key field is not added into the SQL statement for a nested table element.
Is there anything obvious I'm missing ?

$order = new Order($x); // Naturally items in array have no ids

table is linked as follows:

public function details()
{
    return $this->hasMany('App\Detail', 'order_id');
}

there's also belong to on detail:

public function order()
{
    return $this->belongsTo('App\Order','order_id');
}
@troelskn
Copy link
Owner

troelskn commented Jan 1, 2018

Thanks for reporting. Could you show the full code for each model class, as well as the database schema? (Run show create table $TABLENAME in a mysql prompt).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants