本文整理汇总了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();
}
示例2: store
public function store(MenuRequest $request)
{
$input = $request->all();
$data = new Menu($input);
if ($data->save()) {
return response()->json(array('success' => TRUE));
}
}
示例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]);
}
}
示例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));
}
示例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]);
}
}
示例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', "Ошибка");
}
示例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');
}
示例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]);
}
示例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();
}
示例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]);
}
示例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;
}
示例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();
//.........这里部分代码省略.........