I have a $withCount = ['downloads'] in my child model, and when I try to replicate the parent model, it tries to replicate the child model by adding an extra column to the model named downloads_count. here's the error
message": "SQLSTATE[HY000]: General error: 1 table resources has no column named downloads_count (SQL: insert into "resources" ("lesson_id", "type", "title", "url", "deleted_at", "course_id", "downloads_count") values (1, external_resource, Illo aut nisi vitae ut a aut laborum ut., https://www.youtube.com/watch?v=bTqVqk7FSmY, ?, 2, 0))
I have fixed this by adding this line to my duplicateOptions
/**
* Get the options for duplicating the model.
*
* @return DuplicateOptions
*/
public function getDuplicateOptions(): DuplicateOptions
{
return DuplicateOptions::instance()
->excludeRelationColumns(['resources' => ['downloads_count']]);
}
I have a
$withCount = ['downloads']
in my child model, and when I try to replicate the parent model, it tries to replicate the child model by adding an extra column to the model nameddownloads_count
. here's the errorI have fixed this by adding this line to my
duplicateOptions