Пример #1
0
 public function updateBar($id, $name, $link, $sort = "")
 {
     $model = Bar::findOne($id);
     if (!$model) {
         return false;
     }
     $model->name = $name;
     $model->link = $link;
     if ($sort) {
         $model->sort = $sort;
     }
     $model->addTime = date('Y-m-d H:i:s', time());
     $model->addUser = Yii::$app->session->get(Variable::$session_userId_str);
     if ($model->save()) {
         return true;
     }
     return false;
 }
Пример #2
0
 public function actionEditbarlist()
 {
     $user = new AdminUser();
     if (!$user->checkUserIsLogin()) {
         $this->redirect(Variable::$home_url);
         return;
     }
     //        $form=new BarForm();
     //        $req=Yii::$app->request;//创建一个请求对象
     //        $form->setScenario('update');
     //        if($form->load($req->post()) && $form->validate()){
     //            print_r($form);
     //        }
     //        $form->setScenario('update');
     $req = Yii::$app->request;
     //创建一个请求对象
     $id = trim($req->get('id'));
     if (!is_numeric($id) || $id == 0) {
         $this->redirect(Variable::$barIndex_url);
         return;
     }
     $barModel = Bar::findOne($id);
     $barListModel = Bar::find()->where(['parentBar' => $id])->all();
     return $this->render(Variable::$editBarList_view, ['barModel' => $barModel, 'barListModel' => $barListModel]);
 }