public function send() { if ($this->validate()) { if ($stores = Store::findAll(['id' => $this->store_ids])) { foreach ($stores as $store) { $store->sendAdminNotification($this->type, $this->message, $this->title, $this->message_state); } return true; } } else { return false; } }
public function actionAdminNotification(array $ids) { $model = new AdminNotificationForm(); $model->store_ids = $ids; if ($model->load(Yii::$app->request->post()) && $model->send()) { $ok_message = __('Admin notification was send.'); return $this->redirect(['/store/index']); } else { $stores = Store::findAll(['id' => $ids]); return $this->render('admin-notification', ['model' => $model, 'stores' => $stores]); } }