Beispiel #1
0
 /**
  * @return Currency
  */
 public static function current()
 {
     $code = Data::load('currency', function () {
         /** @var User $user */
         $user = \Yii::$app->user->identity;
         return \Yii::$app->user->isGuest ? static::getDefault()->code : Country::findOne($user->country_id)->currency_code;
     });
     return static::get($code);
 }
Beispiel #2
0
}
$items[count($items) - 1]['active'] = true;
echo Nav::widget(['encodeLabels' => false, 'items' => $items, 'options' => ['class' => 'nav-pills']]);
?>

<div class="order-form">
    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'currency_code')->widget(EntityDropDown::className(), ['items' => ArrayHelper::map(Currency::find()->all(), 'code', 'name')]);
?>

    <?php 
echo $form->field($model, 'country_id')->widget(EntityDropDown::className(), array('items' => ArrayHelper::map(Country::find()->all(), 'id', 'name')));
?>

    <?php 
echo $form->field($model, 'user_id')->widget(EntityDropDown::className(), ['items' => ArrayHelper::map(User::find()->all(), 'id', 'name')]);
?>

    <?php 
echo $form->field($model, 'status')->widget(EntityDropDown::className(), ['items' => [Yii::t('app', 'New'), Yii::t('app', 'Closed'), Yii::t('app', 'Canceled')]]);
?>

    <?php 
echo $form->field($model, 'discount');
?>

    <?php 
Beispiel #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCountry()
 {
     return $this->hasOne(Country::className(), ['id' => 'country_id']);
 }
Beispiel #4
0
 /**
  * @return Country[]
  */
 public function api_countries()
 {
     return Data::cache($this->makeCacheKey(), function () {
         return Country::find()->all();
     });
 }