ONYX
ONYX

Reputation: 5859

laravel pivot update column ambigious

Hi have a problem with an update function it says the column updated_at is ambigious and it is. how can I make the updated_at to product.updated_at. my error.

my call to update: $product->attributes()->wherePivot('id', $attribute['id'])->update($input);

my error: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'updated_at' in field list is ambiguous (SQL: update attributes inner join attribute_product on attributes.id = attribute_product.attribute_id set sku = TEST, model = , attribute_product.name = Color, unitprice = 10.00, sellprice = 20.00, discount = 0, active = 0, ordering = 1, updated_at = 2015-03-25 02:44:01 where attribute_product.product_id = 1 and attribute_product.id = 1)

Upvotes: 0

Views: 1283

Answers (1)

terry low
terry low

Reputation: 10628

just add the following line to your product model

const UPDATED_AT = "product.updated_at";

& attribute_product model

const UPDATED_AT = "attribute_product.updated_at";

update your model updated_at to include table name.

Upvotes: 0

Related Questions