示例#1
0
 private function loadPageTitle()
 {
     $pageTitles = config('forone.nav_titles');
     $curRouteName = Route::currentRouteName();
     if (array_key_exists($curRouteName, $pageTitles)) {
         return $pageTitles[$curRouteName];
     } else {
         // load menus title
         $url = URL::current();
         $menus = config('forone.menus');
         foreach ($menus as $title => $menu) {
             if (array_key_exists('children', $menu) && $menu['children']) {
                 foreach ($menu['children'] as $childTitle => $child) {
                     $pageTitle = $this->parseTitle($childTitle, $url, $child['active_uri']);
                     if ($pageTitle) {
                         return $pageTitle;
                     }
                 }
             } else {
                 $pageTitle = $this->parseTitle($title, $url, $menu['active_uri']);
                 if ($pageTitle) {
                     return $pageTitle;
                 }
             }
         }
     }
     return $curRouteName;
 }
示例#2
0
 /**
  * 将数据绑定到视图。
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     //查询当前登录用户
     $admin = Auth::guard('admin')->user();
     if ($admin->admin_name == 'admin') {
         $menus = Menu::orderBy('sort', 'ASC')->get()->toTree();
     } else {
         if ($admin->role) {
             $ids = DB::table('sys_role_function')->where('sys_role_id', $admin->role[0]->id)->pluck('sys_fun_id');
             $menus = Menu::orderBy('sort', 'ASC')->whereIn('id', $ids)->get()->toTree();
         }
     }
     $currentRoute = Route::currentRouteName();
     $list = explode('.', $currentRoute);
     $route = '';
     for ($i = 0; $i < count($list) - 1; $i++) {
         if ($i == 0) {
             $route .= $list[$i];
         } else {
             $route .= '.' . $list[$i];
         }
     }
     $route = $route . '.index';
     $view->with('currentRoute', $route)->with('trees', $menus);
 }
示例#3
0
 /**
  * Track clicked links and form submissions.
  *
  * @param  Request $request
  * @return void
  */
 public function track(Request $request)
 {
     // Don't track if there is no active experiment.
     if (!$this->session->get('experiment')) {
         return;
     }
     // Since there is an ongoing experiment, increase the pageviews.
     // This will only be incremented once during the whole experiment.
     $this->pageview();
     // Check current and previous urls.
     $root = $request->root();
     $from = ltrim(str_replace($root, '', $request->headers->get('referer')), '/');
     $to = ltrim(str_replace($root, '', $request->getPathInfo()), '/');
     // Don't track refreshes.
     if ($from == $to) {
         return;
     }
     // Because the visitor is viewing a new page, trigger engagement.
     // This will only be incremented once during the whole experiment.
     $this->interact();
     $goals = $this->getGoals();
     // Detect goal completion based on the current url.
     if (in_array($to, $goals) or in_array('/' . $to, $goals)) {
         $this->complete($to);
     }
     // Detect goal completion based on the current route name.
     if ($route = Route::currentRouteName() and in_array($route, $goals)) {
         $this->complete($route);
     }
 }
示例#4
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($user = $request->user()) {
         //判断是不是管理员
         $userRoles = Role::all();
         foreach ($userRoles as $r) {
             $roles[] = $r->name;
         }
         if (!$user->hasRole($roles)) {
             redirect()->guest('auth/login');
         }
         //创始人拥有所有权限
         if (!$user->hasRole('Founder')) {
             $can = Route::currentRouteName();
             //当前routeName  exp:user.test
             $res = $request->user()->can($can);
             if (!$res) {
                 return view('admin.noaccess');
             }
         }
     } else {
         return redirect()->guest('auth/login');
     }
     return $next($request);
 }
示例#5
0
 public function compose(View $view)
 {
     $documentForm = \Request::only('responsable_id');
     $route = Route::currentRouteName();
     $users = User::orderBy('name', 'ASC')->lists('name', 'id')->toArray();
     $view->with(compact('documentForm', 'users', 'route'));
 }
 public function handle($request, Closure $next)
 {
     $route_helper = App::make('route_perm_helper');
     if (!$route_helper->hasPermForRoute(Route::currentRouteName())) {
         App::abort('401');
     }
     return $next($request);
 }
示例#7
0
 static function areActiveRoutes(array $routes, $output = "active")
 {
     foreach ($routes as $route) {
         if (Route::currentRouteName() == $route) {
             return $output;
         }
     }
 }
示例#8
0
 /**
  * ### Çoklu Route eşleştirmesi
  *
  * @example ActiveLink::areRoutes([$routeNames])
  * @param  array  $routeNames
  * @param  string $output
  *
  * @return boolean
  */
 public function areRoutes(array $routeNames, $output = "active")
 {
     foreach ($routeNames as $routeName) {
         if (Route::currentRouteName() == $routeName) {
             return $output;
         }
     }
     return null;
 }
 public function listagem()
 {
     /**
      * Usando a Trait PageHeaderTrait,  retorna o nome do Título da Pagina e sua descrição no topo da mesma
      */
     $headerInfo = $this->headerPageName(Route::currentRouteName());
     $usuarios = User::orderBy('name', 'asc')->get();
     return view('usuarios.listagem', compact('usuarios', 'headerInfo'));
 }
示例#10
0
 private function addUser(Request $request)
 {
     $validator = Validator::make($request->all(), ['name' => 'required|max:255|unique:users,name', 'email' => 'required|email|max:255|unique:users,email', 'password' => 'required|confirmed|min:6', 'role' => 'required']);
     if ($validator->fails()) {
         return redirect(route(Route::currentRouteName()))->withErrors($validator->errors());
     } else {
         User::create(['email' => $request->get('email'), 'name' => $request->get('name'), 'password' => bcrypt($request->get('password')), 'role' => $request->get('role')]);
         Session::flash('success', "L'utilisateur a bien été crée.");
     }
     return redirect()->route(Route::currentRouteName());
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     /**
      * Usando a Trait PageHeaderTrait,  retorna o nome do Título da Pagina e sua descrição no topo da mesma
      */
     $headerInfo = $this->headerPageName(Route::currentRouteName());
     $tiposDocumentos = DocumentoTipo::all();
     $pacientes = Paciente::all();
     $medicacaoCategoria = CatMedicacao::all();
     return view('documento.criardocumento', compact('headerInfo', 'tiposDocumentos', 'pacientes', 'medicacaoCategoria'));
 }
示例#12
0
 /**
  * Set the active class to the current opened menu.
  *
  * @param  string|array $route
  * @param  string       $className
  * @return string
  */
 function isActive($route, $className = 'active')
 {
     if (is_array($route)) {
         return in_array(Route::currentRouteName(), $route) ? $className : '';
     }
     if (Route::currentRouteName() == $route) {
         return $className;
     }
     if (strpos(URL::current(), $route)) {
         return $className;
     }
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     // session(['Edicao' => 'Douglas']);
     session()->put('idCatMedicacao', $id);
     /**
      * Usando a Trait PageHeaderTrait,  retorna o nome do Título da Pagina e sua descrição no topo da mesma
      */
     $headerInfo = $this->headerPageName(Route::currentRouteName());
     $categoria = CatMedicacao::findOrFail((int) $id);
     $idReg = $id;
     return view('catmedicacao.edicao', compact('categoria', 'idReg', 'headerInfo'));
 }
示例#14
0
 public function getAvatarAttribute($value)
 {
     //dd(Route::currentRouteName());
     $currentRouteName = Route::currentRouteName();
     $pattern = '/admin./';
     $result = preg_match($pattern, $currentRouteName);
     if (!$result) {
         return url($value);
     } else {
         return $value;
     }
 }
示例#15
0
 public static function link_to_sorting_action($col, $title = null, $special = false)
 {
     if (is_null($title)) {
         $title = str_replace('_', ' ', $col);
         $title = ucfirst($title);
     }
     $indicator = Input::get('s') == $col ? Input::get('o') === 'asc' ? '&uarr;' : '&darr;' : null;
     $parameters = array_merge(Input::get(), ['s' => $col, 'o' => Input::get('o') === 'asc' ? 'desc' : 'asc']);
     if ($special) {
         $parameters = array_merge($parameters, ['sp' => true]);
     }
     return link_to_route(Route::currentRouteName(), "{$title} {$indicator}", $parameters);
 }
示例#16
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     //当前路由
     $currentRouteName = Route::currentRouteName();
     $currentRouteName = preg_replace('/(admin)(\\.[a-z]*)(\\.[a-z]*)/', '$1$2', $currentRouteName);
     if (!empty($currentRouteName)) {
         $menu = Menu::where('route_name', '=', $currentRouteName)->first();
         if (!empty($menu)) {
             $fmenu = Menu::where('id', '=', $menu->fid)->first();
             $view->with('menu', $menu)->with('fmenu', $fmenu);
         }
     } else {
         $dash = 'Dashboard';
         $view->with('dash', $dash);
     }
 }
示例#17
0
 /**
  * 将数据绑定到视图。
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $currentRoute = Route::currentRouteName();
     //查询分类
     $articleCategory = ArticleCategory::all()->toTree();
     //社区分类
     $communityCategory = CommunityCategory::all()->toTree();
     //查询配置项
     $settings = Settings::all();
     foreach ($settings as $key => $value) {
         $options[$value['name']] = $value['value'];
     }
     //查询登录用户
     $user = Auth::guard('web')->user();
     $view->with('loginUser', $user)->with('currentRoute', $currentRoute)->with('articleCategory', $articleCategory)->with('communityCategory', $communityCategory)->with($options);
 }
示例#18
0
 /**
  * 将数据绑定到视图。
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     //查询当前登录用户
     $currentRoute = Route::currentRouteName();
     $list = explode('.', $currentRoute);
     $route = '';
     for ($i = 0; $i < count($list) - 1; $i++) {
         if ($i == 0) {
             $route .= $list[$i];
         } else {
             $route .= '.' . $list[$i];
         }
     }
     $route = $route . '.index';
     $breadcrumb = Menu::with('parent')->where('fun_route_name', $route)->first();
     $view->with('breadcrumb', $breadcrumb);
 }
示例#19
0
 /**
  * 统一返回格式
  * @param $msgcode
  * @param null $message
  * @param null $data
  * @return string
  */
 public static function encodeResult($msgcode, $message = NULL, $data = NULL)
 {
     if ($data == null) {
         $data = new \stdClass();
     }
     $log = new RestLog();
     $log->request = json_encode(Request::all());
     $log->request_route = Route::currentRouteName();
     $log->response = json_encode($data);
     $log->msgcode = $msgcode;
     $log->message = $message;
     $log->client_ip = Request::getClientIp();
     $log->client_useragent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : NULL;
     $log->save();
     $result = array("rest_id" => $log->id, 'msgcode' => $msgcode, 'message' => $message, 'data' => $data, 'version' => self::VERSION, 'servertime' => time());
     return \Response::json($result);
 }
示例#20
0
 function __construct()
 {
     $this->currentUser = Auth::user();
     View::share('currentUser', $this->currentUser);
     //share the config option to all the views
     View::share('siteConfig', config('forone.site_config'));
     if (!$this->pageTitle) {
         $pageTitles = config('forone.nav_titles');
         if ($pageTitles) {
             $curRouteName = Route::currentRouteName();
             if (array_key_exists($curRouteName, $pageTitles)) {
                 $this->pageTitle = $pageTitles[$curRouteName];
             } else {
                 $this->pageTitle = $curRouteName;
             }
         }
     }
     View::share('pageTitle', $this->pageTitle);
 }
示例#21
0
 public function compose(View $view)
 {
     //
     //$menus = $this->category->getAll();
     $categorize = $this->category->getTop()->toArray();
     foreach ($categorize as $key => $value) {
         $child = $this->category->getChild($value['id'])->toArray();
         $categorize[$key]['child'] = $child;
     }
     $currentname = Route::currentRouteName();
     if ($currentname != 'admin') {
         $replace = preg_replace('/(admin)(\\.[a-z]*)(\\.[a-z]*)/', '$1$2', $currentname);
         //dd($replace);
         $currentpid = $this->category->getFidByCurrentName($replace);
     } else {
         $currentpid = 0;
     }
     $view->with('categorize', $categorize)->with('currentname', $replace)->with('currentpid', $currentpid);
 }
 private function saveProduct(Request $request, Product $product)
 {
     $validator = Product::validate($request->all());
     if ($validator->fails()) {
         return redirect(route(Route::currentRouteName()))->withErrors($validator->errors());
     } else {
         if (!is_null($product->id)) {
             $product->update($request->all());
             Session::flash('success', "Le produit a bien été mis à jour.");
         } else {
             $product->fill($request->all());
             $product->save();
             Session::flash('success', "Le produit a bien été crée.");
         }
     }
     if ($param = Route::current()->getParameter('id')) {
         return redirect()->route(Route::currentRouteName(), $param);
     }
     return redirect()->route(Route::currentRouteName());
 }
示例#23
0
 /**
  * 统一返回格式
  * @param $msgcode
  * @param null $message
  * @param null $data
  * @return string
  */
 protected function encodeResult($msgcode, $message = NULL, $data = NULL)
 {
     if ($data == null) {
         $data = new \stdClass();
     }
     $log = new RestLog();
     $log->request = json_encode(Request::except('file'));
     $log->request_route = Route::currentRouteName();
     $log->response = json_encode($data);
     $log->msgcode = $msgcode;
     $log->message = $message;
     $log->client_ip = Request::getClientIp();
     $log->client_useragent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : NULL;
     if (Auth::check()) {
         $log->user_id = Auth::user()->user_id;
     }
     $log->save();
     $result = array("rest_id" => $log->id, 'msgcode' => $msgcode, 'message' => $message, 'date' => $data, 'version' => '1.0', 'servertime' => time());
     return \Response::json($result);
 }
示例#24
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->guest()) {
         if ($request->ajax() || $request->wantsJson()) {
             return response('Unauthorized.', 401);
         }
         return redirect()->guest('dashboard/auth/login');
     }
     $admin = Auth::guard($guard)->user();
     if ($admin->id == 1) {
         return $next($request);
     }
     if ($admin->role->isEmpty()) {
         return abort(404);
     }
     $currentRoute = Route::currentRouteName();
     $list = explode('.', $currentRoute);
     $route = '';
     for ($i = 0; $i < count($list) - 1; $i++) {
         if ($i == 0) {
             $route .= $list[$i];
         } else {
             $route .= '.' . $list[$i];
         }
     }
     $menus = $admin->role[0]->menus;
     $arr = [];
     foreach ($menus as $k => $menu) {
         $route_name = explode('.index', $menu->fun_route_name);
         $arr[$k] = $route_name[0];
     }
     $arr = array_merge(['dashboard'], $arr);
     $route = $route ? $route : 'dashboard';
     if (!in_array($route, $arr)) {
         return abort(404);
     }
     //dd($currentRoute);
     return $next($request);
 }
示例#25
0
 /**
  * Determine the appropriate action parameter to use for a form.
  *
  * If no action is specified, the current request URI will be used.
  *
  * @param  string   $action
  * @param  bool     $https
  * @return string
  */
 protected function route($route = null)
 {
     if (!is_null($route)) {
         return $route;
     }
     return array_merge([Route::currentRouteName()], array_values(Route::getCurrentRoute()->parameters()));
 }
示例#26
0
if (starts_with($currentRouteName, "admin::user.create")) {
    echo $ulLiSubElement;
}
?>
><a href="{{route('admin::user.create')}}">Gebruiker toevoegen</a></li>
							</ul>
						</li>


						<li class="list-divider"></li>

						<?php 
$liMainElement = "";
$ulSubElement = "class=\"collapse\"";
$ulLiSubElement = "";
$currentRouteName = Route::currentRouteName();
$currentRouteAction = Route::currentRouteAction();
if (starts_with($currentRouteAction, "WI\\Core\\Entities")) {
    $liMainElement = "class=\"active-x active-sub\"";
    $ulSubElement = "class=\"collapse in\"";
    $ulLiSubElement = "class=\"active-link\"";
}
?>
								<!--User list item-->
						<li <?php 
echo $liMainElement;
?>
>
							<a href="#">
								<i class="psi-gear-2"></i>
                                    <span class="menu-title">
 protected function filterColumnsByDB()
 {
     if (!($section = strtok(Route::currentRouteName(), '-'))) {
         return;
     }
     $sectionId = DB::table('section')->where('route', '=', $section)->pluck('id');
     if ($this->userService->isAdmin()) {
         return;
     }
     $userColumns = $this->userService->getUserScolumns($sectionId);
     if (empty($this->columnModel)) {
         throw new \Exception('Insufficient Permission');
     }
     foreach ($this->columnModel as $colKey => $colModel) {
         $colFound = false;
         foreach ($userColumns as $scolumn) {
             $columnId = substr($scolumn['name'], strrpos($scolumn['name'], '.') + 1);
             if ($columnId === $colModel['id']) {
                 $colFound = true;
                 break;
             }
         }
         if (!$colFound) {
             unset($this->columnModel[$colKey]);
         }
     }
 }
示例#28
0
 /**
  * Returns the current routes name.
  *
  * @return mixed
  */
 function currentRouteName()
 {
     return Route::currentRouteName();
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(EdicaoMedicacaoFormRequest $request, $id)
 {
     /**
      * Usando a Trait PageHeaderTrait,  retorna o nome do Título da Pagina e sua descrição no topo da mesma
      */
     $headerInfo = $this->headerPageName(Route::currentRouteName());
     if ($id != session("idMedicacao")) {
         abort(403, 'Violação de parâmetros.');
     }
     $updateMedicacao = Medicacao::find($id);
     if ($updateMedicacao->update($request->all())) {
         session()->flash('toastr.success', "Confirmado! O medicamento  " . $request->get('nome') . " foi ATUALIZADO com sucesso!");
     } else {
         session()->flash('toastr.error', "ERRO!  Medicamento " . $request->get('nome') . " NÃO foi ATUALIZADO! Por favor repita a operação");
     }
     session()->forget('idMedicacao');
     return redirect('medicacao/listagem', compact('headerInfo'));
 }
示例#30
0
文件: Player.php 项目: BP4U/BFAdminCP
 /**
  * Generates links to external/internal systems.
  *
  * @return array
  */
 public function getLinksAttribute()
 {
     switch ($this->game->Name) {
         case 'BFHL':
             $game = 'BFH';
             break;
         default:
             $game = $this->game->Name;
     }
     $links = [];
     // Battlelog URL
     if (is_null($this->battlelog)) {
         $links['battlelog'] = sprintf('http://battlelog.battlefield.com/%s/user/%s', strtolower($game), $this->SoldierName);
     } else {
         if ($game == 'BFH') {
             $links['battlelog'] = sprintf('http://battlelog.battlefield.com/%s/agent/%s/stats/%u/pc/', strtolower($game), $this->SoldierName, $this->battlelog->persona_id);
         } else {
             $links['battlelog'] = sprintf('http://battlelog.battlefield.com/%s/soldier/%s/stats/%u/pc/', strtolower($game), $this->SoldierName, $this->battlelog->persona_id);
         }
     }
     if ($game == 'BF4') {
         try {
             if (Route::currentRouteName() != 'player.show') {
                 throw new Exception();
             }
             $request = App::make('guzzle')->get(sprintf('http://api.bf4db.com/api-player.php?%s', http_build_query(['format' => 'json', 'guid' => $this->EAGUID])), ['connect_timeout' => 5]);
             $response = $request->json();
             if ($response['type'] != 'error') {
                 $bf4db_profile = ['url' => $response['data']['bf4db_url'], 'cheatscore' => $response['data']['cheatscore']];
             } else {
                 throw new Exception();
             }
         } catch (Exception $e) {
             $bf4db_profile = ['url' => sprintf('http://bf4db.com/players?name=%s', $this->SoldierName), 'cheatscore' => null];
         }
     }
     $links[] = ['bf3stats' => $game == 'BF3' ? sprintf('http://bf3stats.com/stats_pc/%s', $this->SoldierName) : null, 'bf4stats' => $game == 'BF4' ? sprintf('http://bf4stats.com/pc/%s', $this->SoldierName) : null, 'bfhstats' => $game == 'BFH' ? sprintf('http://bfhstats.com/pc/%s', $this->SoldierName) : null, 'istats' => sprintf('http://i-stats.net/index.php?action=pcheck&player=%s&game=%s&sub=Check+Player', $this->SoldierName, $game), 'metabans' => sprintf('http://metabans.com/search/?phrase=%s', $this->SoldierName), 'bf4db' => $game == 'BF4' ? $bf4db_profile : null, 'chatlogs' => route('chatlog.search', ['pid' => $this->PlayerID]), 'pbbans' => !empty($this->PBGUID) ? sprintf('http://www.pbbans.com/mbi-guid-search-%s.html', $this->PBGUID) : null];
     $links = array_merge($links, $links[0]);
     unset($links[0]);
     return $links;
 }