framework: $withCount breaks replicate()
- Laravel Version: 5.7.13
- PHP Version: 7.2.9
- Database Driver & Version: mysql / ?
Description:
As in other cases(that have all been fixed I think), a model with a polymorphic relation and a $withCount property fails to replicate()
Steps To Reproduce:
class Board extends Model {
public $withCount = ['profiles'];
public function profiles()
{
return $this->morphedByMany(User::class, 'profilable');
}
}
$b = Board::first();
$b2 = $b->replicate();
$b2->save();
Results in the error:
Column not found: 1054 Unknown column 'profiles_count' in 'field list' ...
Expected $b2 to be a new Board instance with same properties as original.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 19 (19 by maintainers)
Sent in a PR: https://github.com/laravel/docs/pull/4795