예제 #1
0
 public function findModel($id)
 {
     if (($model = Adver::findOne($id)) !== null) {
         return $model;
     } else {
         throw new \yii\web\NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
     }
 }
예제 #2
0
파일: Delete.php 프로젝트: rocketyang/admap
 public function run($id)
 {
     $id = (int) $id;
     $output = [];
     if (($model = Adver::findOne($id)) !== null) {
         if ($model->delete()) {
             $output = ['error' => false, 'message' => Yii::t('app', 'Successfully deleted!')];
         }
     }
     if (empty($output)) {
         $output = ['error' => true, 'message' => Yii::t('app', 'The requested page does not exist.')];
     }
     return \yii\helpers\Json::encode($output);
 }
예제 #3
0
 public function run($id)
 {
     $id = (int) $id;
     $output = [];
     if (($model = Adver::findOne($id)) !== null) {
         if ($model->status == Adver::STATUS_ACTIVE) {
             $model->status = Adver::STATUS_DISABLE;
         } else {
             $model->status = Adver::STATUS_ACTIVE;
         }
         if ($model->save()) {
             $output = ['error' => false, 'message' => Yii::t('app', 'Successfully status changed!')];
         }
     }
     if (empty($output)) {
         $output = ['error' => true, 'message' => Yii::t('app', 'The requested page does not exist.')];
     }
     return \yii\helpers\Json::encode($output);
 }