예제 #1
0
 /**
  * Creates a new Menu model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Menu();
     $model->create_user = Yii::$app->user->getId();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $saved = true;
         $model->imagenes = UploadedFile::getInstances($model, 'imagenes');
         foreach ($model->imagenes as $imagen) {
             $image = new Imagen();
             $rnd = rand(0, 99999999);
             $path = Yii::$app->basePath . '/web/images';
             if (!file_exists($path)) {
                 mkdir($path, 0777);
             }
             $path = $path . '/Menu';
             if (!file_exists($path)) {
                 mkdir($path, 0777);
             }
             $path = $path . '/' . $model->id;
             if (!file_exists($path)) {
                 mkdir($path, 0777);
             }
             $imagen->saveAs($path . '/' . $rnd . '.' . $imagen->extension);
             $image->ur_imagen = $rnd . '.' . $imagen->extension;
             $image->save();
         }
         if ($saved) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
예제 #2
0
 /**
  * Creates a new Menu model.
  * If creation is successful, the browser will be redirected to the 'index' page.
  *
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Menu();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index', 'id' => $model->id]);
     }
     return $this->redirect(['index']);
 }
예제 #3
0
 public function actionCreate()
 {
     $model = new Menu();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
예제 #4
0
 /**
  * Creates a new Menu model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $this->view->title = Yii::t('app', 'Create Menu');
     $model = new Menu();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
예제 #5
0
 /**
  * Creates a new Menu model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  *
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Menu();
     $links = Menu::find()->noParents()->active()->all();
     $links = ArrayHelper::map($links, 'id', 'label');
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'links' => $links]);
     }
 }
예제 #6
0
 /**
  * Creates a new Menu model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (!$this->is_access('menu/create')) {
         Yii::$app->session->setFlash('error', $this->errorInfo);
         return $this->redirect($this->redirectUrl);
     }
     $model = new Menu();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         \backend\models\UserLog::addData('menu', $model->menu_id, "新增菜单[{$model->title}]", 'add');
         Yii::$app->session->setFlash('success', '创建菜单成功');
         return $this->redirect(['index']);
     } else {
         Yii::$app->view->params['meta_title'] = '创建菜单';
         $menuTop = $model->menuTop();
         return $this->render('create', ['model' => $model, 'menuTop' => $menuTop]);
     }
 }
예제 #7
0
 /**
  * Creates a new Menu model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCrear()
 {
     $model = new Menu();
     $modelPaginas = new Paginas();
     if ($model->load(Yii::$app->request->post())) {
         $post = Yii::$app->request->post('Menu');
         $model->nombre = $post['nombre'];
         $model->clase = !empty($post['clase']) ? $post['clase'] : '';
         $model->enlace = !empty($post['url']) ? $post['url'] : '#';
         $model->target = !empty($post['target']) ? $post['target'] : '_self';
         $model->padre = !empty($post['padre']) ? $post['padre'] : 0;
         /*
         echo '<pre>';
         print_r($post);
         echo '</pre>';
         die();
         */
         if ($model->save()) {
             return $this->redirect(['view', 'id' => $model->id_menu]);
         }
     } else {
         return $this->render('crear', ['model' => $model, 'modPaginas' => $modelPaginas]);
     }
 }