public function actionDestinationDelete($id)
 {
     /** @var UserShippingAddress $model */
     $model = UserShippingAddress::findOne($id);
     if (!is_null($model) && $model->user_id == $this->getLoggedUser()->id) {
         $model->delete();
     }
     return $this->renderPartial('_sc_destination', ['model' => null]);
 }
Example #2
0
 public function actionDestinationEdit($id)
 {
     if (!is_null($user = $this->getLoggedUser())) {
         /** @var UserShippingAddress $model */
         $model = UserShippingAddress::findOne($id);
         if (!is_null($model) && $model->user_id == $user->id) {
             $form = new DestinationForm($model);
             if (Yii::$app->request->isPost && $form->load(Yii::$app->request->post()) && $form->update($model)) {
                 return $this->renderPartial('_destination', ['model' => $model]);
             }
             return $this->renderPartial('_destination_edit', ['model' => $form, 'id' => $id]);
         }
     }
     return null;
 }