Example #1
0
 /**
  * Получает объект заказа из сессии
  * @param bool $refresh получить заново
  * @return Order
  * @throws \yii\base\InvalidConfigException
  */
 public function getOrder($refresh = false)
 {
     if ($this->_order === null or $refresh) {
         $this->_order = Yii::$app->session->get($this->sessionKey);
         if (!$this->_order) {
             $this->_order = Yii::createObject(["class" => Order::className(), "scenario" => Order::SCENARIO_CONFIRM]);
             $status = Status::find()->byDefault()->one();
             if ($status) {
                 $this->_order->status_id = $status->id;
             }
         }
     }
     $this->_order->clearErrors();
     return $this->_order;
 }
Example #2
0
 /**
  * Возвращает список статусов для выпадающего списка
  * @return array
  */
 public function getStatusList()
 {
     $models = Status::find()->published()->orderBy(["title" => SORT_ASC])->all();
     return ArrayHelper::map($models, "id", "title");
 }
 /**
  * Список статусов заказа
  * @return array|\yii\db\ActiveRecord[]
  */
 public function actionStatuses()
 {
     return Status::find()->published()->all();
 }