public function getExportselected($id, Request $request) { Session::set('exportrec', $id); $excelnm = "menu_" . date("d-m-Y"); Excel::create($excelnm, function ($excel) { $excel->sheet('menus', function ($sheet) { $sheet->mergeCells('A1:W1'); $sheet->row(1, function ($row) { $row->setFontFamily('Comic Sans MS'); $row->setFontSize(30); }); $sheet->row(1, array('Menu Report')); $sheet->row(2, function ($row) { $row->setFontFamily('Comic Sans MS'); $row->setFontSize(15); $row->setFontWeight('bold'); }); $sheet->row(2, array('Record Details')); /* getting data to display - in my case only one record */ $ids = Session::get('exportrec'); $newdatas = explode(",", $ids); $gdatalist = $this->menu_gestion->getallrecords($newdatas); $dataArr = array(); if (is_array($gdatalist) && count($gdatalist) > 0) { $counter = 0; foreach ($gdatalist as $kyy => $dataval) { $dataArr[$counter]['Sl'] = $counter + 1; $dataArr[$counter]['Name'] = $dataval['name']; $dataArr[$counter]['Slug'] = $dataval['menu_slug']; $dataArr[$counter]['Date'] = $dataval['updated_at']; $counter++; } } /* setting column names for data - you can of course set it manually */ $sheet->appendRow(array_keys($dataArr[0])); /* column names */ /* getting last row number (the one we already filled and setting it to bold */ $sheet->row($sheet->getHighestRow(), function ($row) { $row->setFontWeight('bold'); }); /* putting users data as next rows */ foreach ($dataArr as $user) { $sheet->appendRow($user); } }); })->export('xls'); }
/** * @param null $leaf * @return mixed|null * @throws MenuBuilderMenuItemNotFoundException */ public function getLeafMenuItem($leaf = null) { // Get the leaf menu item from the value passed in. try { $leaf = $this->getMenuItem($leaf); return $leaf; } catch (MenuBuilderMenuItemNotFoundException $ex) { // Eat the exception as we want a chance to find it from the current route. } // find by current URL... $currentUrl = $this->getCurrentUrl(); $leaf = $this->menuRepository->findBy('url', $currentUrl); if ($leaf instanceof Menu) { return $leaf; } // Could not find the requested menu item, throwing an exception. throw new MenuBuilderMenuItemNotFoundException("Menu item [" . $leaf . "] not found for URL [" . $currentUrl . "]."); }
/** * @param null $leaf * @return mixed|null * @throws MenuBuilderMenuItemNotFoundException */ public function getLeafMenuItem($leaf = null) { // Get crumbtrail leaf node from session in case a controller wants to force it. // Use session()->pull() to unset/reset the variable after each use. if (session()->has('crumbtrail.leaf')) { $leaf = session()->pull('crumbtrail.leaf'); } // Get the leaf menu item from the value passed in. try { $leaf = $this->getMenuItem($leaf); return $leaf; } catch (MenuBuilderMenuItemNotFoundException $ex) { // Eat the exception as we want a chance to find it from the current route. } // find by current URL... $currentUrl = $this->getCurrentUrl(); $leaf = $this->menuRepository->findBy('url', $currentUrl); if ($leaf instanceof Menu) { return $leaf; } // Could not find the requested menu item, throwing an exception. throw new MenuBuilderMenuItemNotFoundException("Menu item [" . $leaf . "] not found for URL [" . $currentUrl . "]."); }
/** * 删除全部菜单,包括本地数据. * * @param AccountModel $account */ public function deleteAll(AccountModel $account) { $easywechat = app('easywechat'); $easywechat->menu->destroy(); $this->menuRepository->destroyMenu($account->id); }
/** * Lists all Menu models. * @return mixed */ public function actionList() { $searchModel = new MenuRepository(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render(['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
/** * 删除指定菜单. * * @param $menuId * * @return \Illuminate\Http\JsonResponse */ public function destroy($menuId) { $this->menuRepository->delete($menuId); return success('删除成功'); }