Exemple #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $menu = new Menu();
     $menu->event_id = 1;
     $menu->menu_name = "Test Menu";
     $menu->save();
 }
 public function store(MenuRequest $request)
 {
     $input = $request->all();
     $data = new Menu($input);
     if ($data->save()) {
         return response()->json(array('success' => TRUE));
     }
 }
Exemple #3
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();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemple #4
0
 /**
  * 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));
 }
Exemple #5
0
 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]);
     }
 }
Exemple #6
0
 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', "Ошибка");
 }
Exemple #7
0
 /**
  * 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');
 }
 /**
  * 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]);
 }
Exemple #9
0
 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();
 }
Exemple #10
0
 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]);
 }
Exemple #11
0
 /**
  * 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;
 }
Exemple #12
0
 /**
  * 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();
     $admin->menus()->attach("020201", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     $menu = new Menu();
     $menu->id = "020202";
     $menu->label = "Gelombang";
     $menu->link = "/master/gelombang";
     $menu->position = 2;
     $menu->parent_id = "0202";
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     $menu->save();
     $admin->menus()->attach("020202", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     $menu = new Menu();
     $menu->id = "0204";
     $menu->label = "Kelas";
     $menu->link = "/master/kelas";
     $menu->icon = "si si-direction";
     $menu->position = 4;
     $menu->parent_id = "02";
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     $menu->save();
     $admin->menus()->attach("0204", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     $menu = new Menu();
     $menu->id = "0207";
     $menu->label = "Nilai";
     $menu->link = "#";
     $menu->icon = "si si-graph";
     $menu->position = 4;
     $menu->parent_id = "02";
     $menu->privileges = json_encode(['ACCESS']);
     $menu->save();
     $admin->menus()->attach("0207", ['privileges' => 'ACCESS']);
     $menu = new Menu();
     $menu->id = "020701";
     $menu->label = "Kelompok Nilai";
     $menu->link = "/master/nilai/kelompok";
     $menu->position = 1;
     $menu->parent_id = "0207";
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     $menu->save();
     $admin->menus()->attach("020701", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     $menu = new Menu();
     $menu->id = "020702";
     $menu->label = "Jenis Nilai";
     $menu->link = "/master/nilai/jenis";
     $menu->position = 2;
     $menu->parent_id = "0207";
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     $menu->save();
     $admin->menus()->attach("020702", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     $menu = new Menu();
     $menu->id = "0206";
     $menu->label = "Entitas";
     $menu->link = "#";
     $menu->icon = "si si-users";
     $menu->position = 5;
     $menu->parent_id = "02";
     $menu->privileges = json_encode(['ACCESS']);
     $menu->save();
     $admin->menus()->attach("0206", ['privileges' => 'ACCESS']);
     $menu = new Menu();
     $menu->id = "020601";
     $menu->label = "Instansi";
     $menu->link = "/master/entitas/instansi";
     $menu->position = 1;
     $menu->parent_id = "0206";
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     $menu->save();
     $admin->menus()->attach("020601", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     $menu = new Menu();
     $menu->id = "020602";
     $menu->label = "Guru / Peserta";
     $menu->link = "/master/entitas/guru";
     $menu->position = 2;
     $menu->parent_id = "0206";
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     $menu->save();
     $admin->menus()->attach("020602", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     $menu = new Menu();
     $menu->id = "020604";
     $menu->label = "Widyaiswara";
     $menu->link = "/master/entitas/widyaiswara";
     $menu->position = 4;
     $menu->parent_id = "0206";
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     $menu->save();
     $admin->menus()->attach("020604", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     $menu = new Menu();
     $menu->id = "020605";
     $menu->label = "Evaluator";
     $menu->link = "/master/entitas/evaluator";
     $menu->position = 5;
     $menu->parent_id = "0206";
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     $menu->save();
     $admin->menus()->attach("020605", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     $menu = new Menu();
     $menu->id = "020606";
     $menu->label = "Stakeholder";
     $menu->link = "/master/entitas/stakeholder";
     $menu->position = 6;
     $menu->parent_id = "0206";
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     $menu->save();
     $admin->menus()->attach("020606", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     /* Pengolahan Data */
     $menu = new Menu();
     $menu->id = "03";
     $menu->label = "Pengolahan Data";
     $menu->link = "#";
     $menu->position = 2;
     $menu->parent_id = null;
     $menu->privileges = json_encode(['ACCESS']);
     $menu->save();
     $admin->menus()->attach("03", ['privileges' => 'ACCESS']);
     $widyaiswara->menus()->attach("03", ['privileges' => 'ACCESS']);
     $evaluator->menus()->attach("03", ['privileges' => 'ACCESS']);
     $menu = new Menu();
     $menu->id = "0301";
     $menu->label = "Nilai";
     $menu->link = "#";
     $menu->position = 1;
     $menu->parent_id = "03";
     $privileges = ['ACCESS'];
     $menu->privileges = json_encode($privileges);
     $menu->save();
     $admin->menus()->attach("0301", ['privileges' => implode(',', $privileges)]);
     $widyaiswara->menus()->attach("0301", ['privileges' => implode(',', $privileges)]);
     $evaluator->menus()->attach("0301", ['privileges' => implode(',', $privileges)]);
     $menu = new Menu();
     $menu->id = "030101";
     $menu->label = "Pre-Test & Post-Test";
     $menu->link = "/olahdata/nilai/pre-post";
     $menu->position = 1;
     $menu->parent_id = "0301";
     $privileges = ['ACCESS', 'ADD', 'DELETE', 'EDIT'];
     $menu->privileges = json_encode($privileges);
     $menu->save();
     $admin->menus()->attach("030101", ['privileges' => implode(',', $privileges)]);
     $evaluator->menus()->attach("030101", ['privileges' => implode(',', $privileges)]);
     $menu = new Menu();
     $menu->id = "030102";
     $menu->label = "Nilai Harian";
     $menu->link = "/olahdata/nilai/harian";
     $menu->position = 2;
     $menu->parent_id = "0301";
     $privileges = ['ACCESS', 'ADD', 'DELETE', 'EDIT'];
     $menu->privileges = json_encode($privileges);
     $menu->save();
     $admin->menus()->attach("030102", ['privileges' => implode(',', $privileges)]);
     $widyaiswara->menus()->attach("030102", ['privileges' => implode(',', $privileges)]);
     $evaluator->menus()->attach("030102", ['privileges' => implode(',', $privileges)]);
     $menu = new Menu();
     $menu->id = "0302";
     $menu->label = "Kuesioner";
     $menu->link = "/olahdata/kuesioner";
     $menu->position = 2;
     $menu->parent_id = "03";
     $privileges = ['ACCESS', 'ADD', 'DELETE', 'EDIT'];
     $menu->privileges = json_encode($privileges);
     $menu->save();
     $admin->menus()->attach("0302", ['privileges' => implode(',', $privileges)]);
     /* KEAMANAN */
     $menu = new Menu();
     $menu->id = "09";
     $menu->label = "Keamanan & Kewenangan";
     $menu->link = "#";
     $menu->position = 99;
     $menu->privileges = json_encode(['ACCESS']);
     $menu->save();
     $admin->menus()->attach("09", ['privileges' => 'ACCESS']);
     // $menu = new Menu;
     // $menu->id = "0901";
     // $menu->label = "Data Pengguna";
     // $menu->icon = "si si-users";
     // $menu->link = "/security/users";
     // $menu->position = 1;
     // $menu->parent_id = "09";
     // $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     // $menu->save();
     // $admin->menus()->attach("0901", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     $menu = new Menu();
     $menu->id = "0902";
     $menu->icon = "si si-directions";
     $menu->label = "Hak Akses";
     $menu->link = "/security/roles";
     $menu->position = 1;
     $menu->parent_id = "09";
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     $menu->save();
     $admin->menus()->attach("0902", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     // MENU KHUSUS GURU
     // $menu = new Menu;
     // $menu->id = "11";
     // $menu->icon = "si si-user";
     // $menu->label = "Profil";
     // $menu->link = "/guru/profil";
     // $menu->position = 1;
     // $menu->parent_id = null;
     // $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     // $menu->save();
     // $guru->menus()->attach("11", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     $menu = new Menu();
     $menu->id = "12";
     $menu->icon = "si si-graph";
     $menu->label = "Nilai";
     $menu->link = "/guru/nilai";
     $menu->position = 2;
     $menu->parent_id = null;
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     $menu->save();
     $guru->menus()->attach("12", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
     $menu = new Menu();
     $menu->id = "13";
     $menu->icon = "si si-question";
     $menu->label = "Kuesioner";
     $menu->link = "/guru/kuesioner";
     $menu->position = 3;
     $menu->parent_id = null;
     $menu->privileges = json_encode(['ACCESS', 'ADD', 'DELETE', 'EDIT']);
     $menu->save();
     $guru->menus()->attach("13", ['privileges' => 'ACCESS,ADD,EDIT,DELETE']);
 }