當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Menu::save方法代碼示例

本文整理匯總了PHP中app\models\Menu::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Menu::save方法的具體用法?PHP Menu::save怎麽用?PHP Menu::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Menu的用法示例。


在下文中一共展示了Menu::save方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $menu = new Menu();
     $menu->event_id = 1;
     $menu->menu_name = "Test Menu";
     $menu->save();
 }
開發者ID:rob-meh,項目名稱:table-seater,代碼行數:12,代碼來源:MenuSeeder.php

示例2: store

 public function store(MenuRequest $request)
 {
     $input = $request->all();
     $data = new Menu($input);
     if ($data->save()) {
         return response()->json(array('success' => TRUE));
     }
 }
開發者ID:brutalcrozt,項目名稱:SI-Sekolah-L5,代碼行數:8,代碼來源:MenuController.php

示例3: actionCreate

 /**
  * 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();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
開發者ID:altairsoft,項目名稱:plutos,代碼行數:14,代碼來源:MenuController.php

示例4: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Menu();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     return $this->render('create', array('model' => $model));
 }
開發者ID:chaimvaid,項目名稱:linet3,代碼行數:14,代碼來源:MenuController.php

示例5: actionCreate

 public function actionCreate()
 {
     \Yii::$app->language = 'vi-VN';
     $model = new Menu();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['list']);
     } else {
         $model->status = Menu::STATUS_ENABLED;
         $model->url = '#';
         return $this->render('create', ['model' => $model]);
     }
 }
開發者ID:phucnv206,項目名稱:pharma,代碼行數:12,代碼來源:MenuController.php

示例6: postCreate

 public function postCreate()
 {
     $validator = Validator::make(Input::all(), Menu::$rules);
     if ($validator->passes()) {
         $menu = new Menu();
         $menu->title = Input::get('title');
         $menu->url = Input::get('url');
         $menu->weight = Menu::count();
         $menu->save();
         return Redirect::back()->with('message', "Элемент меню добавлен");
     }
     return Redirect::back()->with('message', "Ошибка");
 }
開發者ID:venomir,項目名稱:tc,代碼行數:13,代碼來源:MenuController.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['key' => 'required|unique:menu|max:255', 'name' => 'required', 'sort' => 'required|integer']);
     if ($validator->fails()) {
         return redirect('admin/menu/create')->withErrors($validator)->withInput();
     }
     $menu = new Menu();
     $menu->key = $request->key;
     $menu->name = $request->name;
     $menu->sort = $request->sort;
     $menu->save();
     return redirect('admin/menu');
 }
開發者ID:pechatny,項目名稱:kolizej,代碼行數:19,代碼來源:MenuController.php

示例8: actionCreate

 /**
  * 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();
     try {
         if ($model->load($_POST) && $model->save()) {
             return $this->redirect(Url::previous());
         } elseif (!\Yii::$app->request->isPost) {
             $model->load($_GET);
         }
     } catch (\Exception $e) {
         $msg = isset($e->errorInfo[2]) ? $e->errorInfo[2] : $e->getMessage();
         $model->addError('_exception', $msg);
     }
     return $this->render('create', ['model' => $model]);
 }
開發者ID:febfeb,項目名稱:yii2-basic-ready,代碼行數:20,代碼來源:MenuController.php

示例9: store

 public function store()
 {
     $input = Input::only('title', 'type');
     $validate = $this->validate($input);
     if ($validate->passes()) {
         $tag = Str::slug($input['title']);
         //save
         $menu = new Menu();
         $menu->title = $input['title'];
         $menu->type = $input['type'];
         $menu->tag = "[{$tag}]";
         $menu->save();
         return Redirect::to('admin/menus')->withStatus('Menu Created');
     }
     return Redirect::back()->withStatus($validate->errors(), 'danger')->withInput();
 }
開發者ID:nova-framework,項目名稱:cms,代碼行數:16,代碼來源:Menus.php

示例10: actionAdminList

 function actionAdminList()
 {
     $query = new Query();
     $query->addSelect('c.*')->from([Menu::tableName() . ' c']);
     $provider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100]]);
     $model = new MenuForm();
     if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
         $object = new Menu();
         $object->name = $model->name;
         $object->url = $model->url;
         $object->sort_int = 0;
         $object->active = 1;
         $object->parent_id = 0;
         $object->save();
         $model->command_reload_page = 1;
         //return $this->redirect(Url::toRoute(['posts/menu-list']));
     }
     $this->layout = 'admin';
     return $this->render('//admin/menu/list.php', ['provider' => $provider, 'model' => $model]);
 }
開發者ID:hysdop,項目名稱:YobaCMS,代碼行數:20,代碼來源:MenuControllerOFF.php

示例11: savePost

 /**
  * savePost.
  *
  * @param App\Models\Menu $menu  菜單
  * @param array           $input input
  *
  * @return App\Models\Menu
  */
 public function savePost($menu, $input)
 {
     $menu->fill($input);
     $menu->save();
     return $menu;
 }
開發者ID:renyang9876,項目名稱:viease,代碼行數:14,代碼來源:MenuRepository.php

示例12: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $admin = Role::byLabel('admin')->first();
     $widyaiswara = Role::byLabel('widyaiswara')->first();
     $guru = Role::byLabel('guru')->first();
     $evaluator = Role::byLabel('evaluator')->first();
     $stakeholder = Role::byLabel('stakeholder')->first();
     $menu = new Menu();
     $menu->id = "01";
     $menu->label = "Dashboard";
     $menu->link = "/";
     $menu->icon = "si si-speedometer";
     $menu->position = 1;
     $menu->privileges = json_encode(['ACCESS']);
     $menu->save();
     $admin->menus()->attach("01", ['privileges' => 'ACCESS']);
     $widyaiswara->menus()->attach("01", ['privileges' => 'ACCESS']);
     $guru->menus()->attach("01", ['privileges' => 'ACCESS']);
     $evaluator->menus()->attach("01", ['privileges' => 'ACCESS']);
     $stakeholder->menus()->attach("01", ['privileges' => 'ACCESS']);
     /* Master */
     $menu = new Menu();
     $menu->id = "02";
     $menu->label = "Data Master";
     $menu->link = "#";
     $menu->icon = "si si-bulb";
     $menu->position = 2;
     $menu->privileges = json_encode(['ACCESS']);
     $menu->save();
     $admin->menus()->attach("02", ['privileges' => 'ACCESS']);
     $menu = new Menu();
     $menu->id = "0205";
     $menu->label = "Wilayah Geografis";
     $menu->link = "#";
     $menu->icon = "si si-globe";
     $menu->position = 1;
     $menu->parent_id = "02";
     $menu->privileges = json_encode(['ACCESS']);
     $menu->save();
     $admin->menus()->attach("0205", ['privileges' => 'ACCESS']);
     $menu = new Menu();
     $menu->id = "020501";
     $menu->label = "Provinsi";
     $menu->link = "/master/geografis/provinsi";
     $menu->position = 1;
     $menu->parent_id = "0205";
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'EDIT', 'DELETE']);
     $menu->save();
     $admin->menus()->attach("020501", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     $menu = new Menu();
     $menu->id = "020502";
     $menu->label = "Kota & Kabupaten";
     $menu->link = "/master/geografis/kota";
     $menu->position = 1;
     $menu->parent_id = "0205";
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'EDIT', 'DELETE']);
     $menu->save();
     $admin->menus()->attach("020502", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     // $menu = new Menu;
     // $menu->id = "020503";
     // $menu->label = "Kecamatan";
     // $menu->link = "/master/geografis/kecamatan";
     // $menu->position = 1;
     // $menu->parent_id = "0205";
     // $menu->privileges = json_encode(['ACCESS','ADD','EDIT','DELETE']);
     // $menu->save();
     // $admin->menus()->attach("020503", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     $menu = new Menu();
     $menu->id = "0201";
     $menu->label = "Program Diklat";
     $menu->link = "/master/diklat";
     $menu->icon = "si si-badge";
     $menu->position = 1;
     $menu->parent_id = "02";
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     $menu->save();
     $admin->menus()->attach("0201", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     $menu = new Menu();
     $menu->id = "0202";
     $menu->label = "Periode & Gelombang";
     $menu->link = "#";
     $menu->icon = "si si-clock";
     $menu->position = 2;
     $menu->parent_id = "02";
     $menu->privileges = json_encode(['ACCESS']);
     $menu->save();
     $admin->menus()->attach("0202", ['privileges' => 'ACCESS']);
     $menu = new Menu();
     $menu->id = "020201";
     $menu->label = "Periode";
     $menu->link = "/master/periode";
     $menu->position = 1;
     $menu->parent_id = "0202";
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     $menu->save();
//.........這裏部分代碼省略.........
開發者ID:miarizkim,項目名稱:simonev,代碼行數:101,代碼來源:MenuTableSeeder.php


注:本文中的app\models\Menu::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。