public function up() { $all = \app\models\Chenneling::query(['description' => null])->all(); foreach ($all as $item) { $i = new \app\models\Chenneling($item); $i->update(['description' => \app\services\GsssHtml::getMiniText($i->getField('content'))]); } }
/** * @param null $fieldsCols * * @return \app\models\Chenneling */ public function insert($fieldsCols = null) { $row = parent::insert(['beforeInsert' => function ($fields) { $fields['date_insert'] = gmdate('YmdHis'); $fields['id_string'] = Str::rus2translit($fields['header']); $fields['date'] = gmdate('Y-m-d'); return $fields; }]); $item = new \app\models\Chenneling($row); if ($this->is_add_image) { $fields = ['content' => Html::tag('p', Html::img(\cs\Widget\FileUpload2\FileUpload::getOriginal($item->getField('img')), ['class' => 'thumbnail', 'style' => 'width:100%;', 'alt' => $item->getField('header')])) . $item->getField('content')]; } if ($row['description'] == '') { $fields['description'] = GsssHtml::getMiniText($row['content']); } $item->update($fields); return $item; }