/** * @return string */ public function run() { $this->model->setAttributes($this->attributes); return $this->render('manage', ['model' => $this->model, 'attribute' => $this->attribute, 'list' => ArrayHelper::map(Magic::find()->where($this->attributes)->orderBy(['position' => SORT_ASC, 'id' => SORT_ASC])->all(), 'id', function ($row) { return $this->render('_item', ['row' => $row]); })]); }
public function init() { /* @var $row Magic */ $model = Magic::find()->where($this->options)->orderBy(['position' => SORT_ASC, 'id' => SORT_ASC])->all(); foreach ($model as $row) { $type = $row->getType(); $this->list = ArrayHelper::merge($this->list, [$type => [$row]]); } parent::init(); }
public function delete() { $images = Magic::find()->where(['module' => $this->formName(), 'group_id' => 0, 'record_id' => $this->id])->all(); if ($images) { foreach ($images as $image) { $image->delete(); } } parent::delete(); }
/** * @param \app\modules\magic\models\Magic $model * @return string */ protected function display(Magic $model) { $model->scenario = 'many'; return $this->renderAjax('@app/modules/magic/widgets/views/manage', ['model' => $model, 'attribute' => $model::ATTRIBUTE, 'list' => ArrayHelper::map(Magic::find()->where(['module' => $model->module, 'group_id' => $model->group_id, 'record_id' => $model->record_id])->orderBy(['position' => SORT_ASC, 'id' => SORT_ASC])->all(), 'id', function ($row) { return $this->renderPartial('@app/modules/magic/widgets/views/_item', ['row' => $row]); })]); }