Esempio n. 1
0
 public function getMenuSortableList(Request $request)
 {
     $id = $request->id;
     $validator = Validator::make($request->all(), ['id' => 'required|min:0', 'location' => 'required_if:id,0|min:1|exists:menu_locations,id']);
     if ($validator->fails()) {
         return ['success' => false, 'message' => $validator->errors()->first()];
     }
     if ($id != 0) {
         $parent = Menu::findOrFail($id);
     } else {
         $parent = new Menu();
         $parent->id = 0;
         $parent->location_id = $request->location;
     }
     $list = $parent->children()->where('location_id', $parent->location_id)->ordered()->get();
     $canceled_id = $this->CANCELED;
     return ['success' => true, 'data' => view('admin.menu.list', compact('parent', 'list', 'canceled_id'))->render(), 'container' => $request->container];
 }