Exemplo n.º 1
0
 /**
  * @param $id
  * @param \Illuminate\Http\Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function sorting($id, Request $request)
 {
     if (is_array($request->get('order')) && $request->get('order')) {
         foreach ($request->get('order') as $key => $value) {
             if (Menu::whereGroupId($id)->whereId($key)->count()) {
                 $menu = Menu::find($key);
                 $menu->update(['order_id' => $value]);
             }
         }
     }
     return $this->redirect->back();
 }
Exemplo n.º 2
0
 /**
  * @param \Notadd\Menu\Requests\MenuCreateRequest $request
  * @param $id
  * @return $this|\Illuminate\Http\RedirectResponse
  */
 public function update(MenuCreateRequest $request, $id)
 {
     $menu = Menu::findOrFail($id);
     if ($request->hasFile('icon_image') && $request->file('icon_image')->isValid()) {
         $file_name = Str::random() . '.' . $request->file('icon_image')->getClientOriginalExtension();
         $request->file('icon_image')->move('uploads/menus/', $file_name);
         $request->offsetSet('icon_image', 'uploads/menus/' . $file_name);
     }
     $request->files->replace();
     if ($menu->update($request->all())) {
         return $this->redirect->back();
     } else {
         return $this->redirect->back()->withInput()->withErrors('保存失败!');
     }
 }
Exemplo n.º 3
0
 /**
  * @param $group_id
  * @return array
  */
 public function build($group_id)
 {
     $menus = [];
     Menu::buildMenus($group_id, 0, $menus);
     return $menus;
 }