You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating / updating / deleting a child belonging to a parent through a MorphTo relation Eloquent tries to updated the parents updated_at column regardless of the parents $timestamps property when the parent is listed in $touches.
Because this is a polymorphic relation and not all parents may have timestamps I would expect that parents with $timestamps = false are ignored when touching.
(I guess this may not only be relevant for MorphTo relations but others as well)
Steps To Reproduce:
Parent.php
class Parent extends Model
{
public $timestamps = false;
public function children(): MorphMany
{
return $this->morphMany(Child::class, 'children');
}
}
Child.php
class Child extends Model
{
protected $touches = ['parent'];
public function parent(): MorphTo
{
return $this->morphTo();
}
}
$parent->children()->save(new Child()); throws Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such column: updated_at (SQL: update "parents" set "updated_at" = 2019-05-28 11:02:21 where "parents"."id" = 1)
The text was updated successfully, but these errors were encountered:
Description:
When creating / updating / deleting a child belonging to a parent through a
MorphTo
relation Eloquent tries to updated the parentsupdated_at
column regardless of the parents$timestamps
property when the parent is listed in$touches
.Because this is a polymorphic relation and not all parents may have timestamps I would expect that parents with
$timestamps = false
are ignored when touching.(I guess this may not only be relevant for
MorphTo
relations but others as well)Steps To Reproduce:
Parent.php
Child.php
$parent->children()->save(new Child());
throwsIlluminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such column: updated_at (SQL: update "parents" set "updated_at" = 2019-05-28 11:02:21 where "parents"."id" = 1)
The text was updated successfully, but these errors were encountered: