Clear schedule date when duplicating newsletter

[MAILPOET-2080]
This commit is contained in:
Ján Mikláš
2019-05-21 13:54:55 +02:00
committed by M. Shull
parent 7dc3171629
commit ab7f18c274

View File

@@ -411,8 +411,17 @@ class Newsletter extends Model {
$options = NewsletterOption::where('newsletter_id', $this->id)
->findMany();
$ignored_option_field_ids = Helpers::flattenArray(
NewsletterOptionField::whereIn('name', ['isScheduled', 'scheduledAt'])
->select('id')
->findArray()
);
if (!empty($options)) {
foreach ($options as $option) {
if (in_array($option->option_field_id, $ignored_option_field_ids)) {
continue;
}
$relation = NewsletterOption::create();
$relation->newsletter_id = $duplicate->id;
$relation->option_field_id = $option->option_field_id;