/**
  * 메뉴의 링크를 생성하여 반환한다. 메뉴에 link정보가 있을 경우 link정보를 우선 사용하여 생성한다.
  * 그 다음으로 메뉴에 연결된 route정보를 사용하여 링크를 생성한다.
  *
  * @return Route|mixed|string
  * @throws \Exception
  */
 public function link()
 {
     if ($this->display === false) {
         return '#';
     }
     // menu에 링크 정보가 있을 경우
     if ($this->link !== null) {
         if ($this->link instanceof Closure) {
             return $this->link();
         } else {
             return $this->link;
         }
     }
     // 어떤 링크정보도 찾을 수 없으면 #
     if ($this->route === null) {
         return '#';
     }
     // route 정보 사용
     if ($name = $this->route->getName()) {
         return route($name);
     } elseif ($action = $this->route->getActionName()) {
         if ($action !== 'Closure') {
             return action($action);
         }
     }
     throw new LinkNotFoundException('admin 메뉴가 지정된 route는 name(as)이 지정되어 있거나 Controller action이어야 합니다.');
 }
 protected function filterRouteAsClass(Route $route)
 {
     if ($this->option('name') && !str_contains($route->getName(), $this->option('name')) || $this->option('path') && !str_contains(implode('|', $route->methods()) . ' ' . $route->uri(), $this->option('path'))) {
         return null;
     }
     return $route;
 }
Example #3
0
 /**
  * Determines if routes has to be authorized.
  *
  * @return bool
  */
 protected function hasToBeAuthorized()
 {
     if (in_array($this->route->getName(), self::$except)) {
         return false;
     }
     return (bool) $this->route->getName();
 }
Example #4
0
 /**
  * Get the route information for a given route.
  *
  * @param $route \Illuminate\Routing\Route
  * @param $filter string
  * @param $namespace string
  *
  * @return array
  */
 protected function getRouteInformation(Route $route, $filter, $namespace)
 {
     $host = $route->domain();
     $methods = $route->getMethods();
     $uri = $route->uri();
     $name = $route->getName();
     $action = $route->getActionName();
     $jsroute = array_get($route->getAction(), 'jsroute', null);
     if (!empty($namespace)) {
         $a = $route->getAction();
         if (isset($a['controller'])) {
             $action = str_replace($namespace . '\\', '', $action);
         }
     }
     switch ($filter) {
         case 'all':
             if ($jsroute === false) {
                 return null;
             }
             break;
         case 'only':
             if ($jsroute !== true) {
                 return null;
             }
             break;
     }
     return compact('host', 'methods', 'uri', 'name', 'action');
 }
 /**
  * 메뉴의 링크를 생성하여 반환한다. 메뉴에 link정보가 있을 경우 link정보를 우선 사용하여 생성한다.
  * 그 다음으로 메뉴에 연결된 route정보를 사용하여 링크를 생성한다.
  *
  * @return Route|mixed|string
  * @throws \Exception
  */
 public function link()
 {
     if ($this->display === false) {
         return null;
     }
     // menu에 링크 정보가 있을 경우
     if ($this->link !== null) {
         if ($this->link instanceof Closure) {
             return $this->link();
         } else {
             return $this->link;
         }
     }
     // 어떤 링크정보도 찾을 수 없으면 #
     if ($this->route === null) {
         return null;
     }
     // route 정보 사용
     if ($name = $this->route->getName()) {
         return route($name);
     } elseif ($action = $this->route->getActionName()) {
         if ($action !== 'Closure') {
             return action($action);
         }
     }
     throw new LinkNotFoundException();
 }
Example #6
0
 public function rules(Route $route)
 {
     if ($route->getName() == 'backend.backend.users.update') {
         $rules = ['user.email' => 'required|unique:backend_users,email,' . $route->parameter('id'), 'user.active' => 'required', 'groups' => 'required'];
     } else {
         $rules = ['user.email' => 'required|unique:backend_users,email', 'user.active' => 'required', 'groups' => 'required', 'password' => 'required'];
     }
     return $rules;
 }
Example #7
0
 /**
  * @return $this
  */
 protected function setupDefaults()
 {
     $this->route = Route::current();
     if (method_exists($this->route, 'getName') && !empty($this->route->getName())) {
         $this->template = $this->route()->getName();
         $this->setTypeAndFormAction()->setTypeName()->setModelInstance();
     }
     return $this;
 }
 private function generateTableRow(Route $route)
 {
     $tableRow = "";
     $tableRow .= '<tr>';
     $tableRow .= '<td>' . $route->getName() . '</td>';
     $tableRow .= '<td><a href="' . $this->appUrl . '/' . $route->getUri() . '" target="_blank">' . $this->appUrl . '/' . $route->getPath() . '</a></td>';
     $tableRow .= '</tr>';
     return $tableRow;
 }
Example #9
0
 /**
  * Returns the output if the specified route
  * is the current route.
  *
  * @param string $route
  *
  * @return null|string
  */
 public function route($route)
 {
     $current = $this->route->getName();
     if ($this->containsWildcard($route)) {
         // If the specified route contains a wildcard we'll remove it.
         $route = $this->stripWildcard($route);
         if (str_contains($current, $route)) {
             // We'll check if the stripped route exists inside the current
             // route and return the output if that is the case.
             return $this->output;
         }
     }
     // If the route does not contain a wildcard we'll check if the
     // current route equals the specified route loosely.
     if ($current == $route) {
         return $this->output;
     }
     return;
 }
Example #10
0
 /**
  * Add the necessary where clauses to the route based on its initial registration.
  *
  * @param  \Illuminate\Routing\Route  $route
  * @return \Illuminate\Routing\Route
  */
 protected function addWhereClausesToRoute($route)
 {
     foreach ($this->get_patterns_defaults() as $key => $value) {
         $route->defaults($key, $value);
     }
     if ($route->getName() == 'page') {
         #dd($route);
     }
     parent::addWhereClausesToRoute($route);
 }
Example #11
0
 /**
  * Check the current route name with one or some patterns
  *
  * @param array $patterns
  *
  * @return bool
  */
 public function checkRoutePattern(array $patterns)
 {
     if (!$this->route) {
         return false;
     }
     $routeName = $this->route->getName();
     foreach ($patterns as $p) {
         if (str_is($p, $routeName)) {
             return true;
         }
     }
     return false;
 }
Example #12
0
 /**
  * User has access to a route ?
  */
 public function hasAccess(\Illuminate\Routing\Route $route, \Illuminate\Http\Request $request, $value = 'chose')
 {
     $value = $value ?: $route->getName();
     try {
         $user = Sentry::getUser();
         if (!$user->hasAccess($value)) {
             App::abort(403);
         }
     } catch (UserNotFoundException $e) {
         Notification::error($e->getMessage() . '\\n' . $request->fullUrl());
         return Redirect::guest(route('login'));
     }
 }
Example #13
0
 public function setPageType(Route $route, CmsRequestInterface $request)
 {
     if (!($cmsPath = $request->getCmsPath())) {
         return;
     }
     // If a page match did happen the request already has a pagetype
     if ($cmsPath->isCmsPath()) {
         return;
     }
     if (!($pageType = $this->pageTypes->getByRouteName($route->getName()))) {
         return;
     }
     $request->getCmsPath()->setPageType($pageType);
 }
Example #14
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id, Route $route)
 {
     $action = $route->getName();
     $action = explode('.', $action);
     $action = array_pop($action);
     //Listas
     $generos = Sexo::all();
     $estados = Estado::orderBy('descripcion')->lists('descripcion', 'id');
     $escuelas = Escuela::all()->lists('nombre', 'id');
     $grupos = Grupo::all()->lists('descripcion', 'id');
     //
     $maestro = User::findOrFail($id);
     $form_data = ['route' => ['admin.maestro.update', $maestro->id], 'method' => 'PUT'];
     $title = 'Editar maestro';
     return view('admin.maestro.form')->with(compact('maestro', 'form_data', 'title', 'generos', 'estados', 'grupos', 'escuelas', 'action'));
 }
Example #15
0
 function parseRoute(Route $route)
 {
     $this->pushBreadcrumb(self::HOME_ROUTE);
     $routeName = $route->getName();
     Breadcrumbs::register($routeName, function ($breadcrumbs) use($routeName) {
         $specifiers = func_get_args();
         array_shift($specifiers);
         $specific = [];
         $parts = $this->expandRoute($routeName);
         $parent = null;
         while ($part = array_shift($parts)) {
             if (strpos($parent, '.' . static::INDEX_ROUTE) !== false) {
                 $parentRoute = str_replace('.' . static::INDEX_ROUTE, '', $parent);
             } else {
                 $parentRoute = $parent;
             }
             $current = $parent ? "{$parentRoute}.{$part}" : $part . '.' . static::INDEX_ROUTE;
             $resolved = $this->resolveRoute($current, $part);
             $route = explode('.', $resolved);
             $part = array_pop($route);
             $specifier = null;
             if (str_contains($part, $this->entitied)) {
                 if (!$this->lastIs(static::INDEX_ROUTE)) {
                     $this->pushBreadcrumb($this->traversed($resolved, static::INDEX_ROUTE), $specific);
                 }
                 $specifier = array_shift($specifiers);
                 $specific[] = $specifier;
             }
             if ($this->routeExists($resolved)) {
                 $this->pushBreadcrumb($resolved, $specific);
             } else {
                 throw new \Exception("Route [{$current}] don't exists");
             }
             $parent = $current;
         }
         $unique = [];
         $parent = null;
         foreach ($this->crumbs as $route) {
             if (array_search($route[0], $unique) !== false) {
                 continue;
             }
             $this->pushRoute($breadcrumbs, $parent, $route[0], $route[1]);
             $unique[] = $parent = $route[0];
         }
     });
 }
Example #16
0
 /**
  * Get the route information for a given route.
  *
  * @param  string  $name
  * @param  \Illuminate\Routing\Route  $route
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     $uri = implode('|', $route->methods()) . ' ' . $route->uri();
     return $this->filterRoute(array('host' => $route->domain(), 'uri' => $uri, 'name' => $route->getName(), 'action' => $route->getActionName(), 'prefix' => $route->getPrefix(), 'method' => $route->methods()[0]));
 }
Example #17
0
 /**
  * Get the route information for a given route.
  *
  * @param  \Illuminate\Routing\Route $route
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     list($controller, $action) = explode("@", $route->getActionName());
     return ['host' => $route->domain(), 'method' => implode('|', $route->methods()), 'uri' => $route->uri(), 'name' => $route->getName(), 'controller' => $controller, 'action' => $action, 'resource' => $route->getActionName(), 'middleware' => Collection::make($this->getMiddleware($route))];
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Route $route, $id)
 {
     return view('pages.category_show')->with('data', ['item' => $this->getModel()[$id], 'body_class' => str_replace('.', '_', $route->getName())]);
 }
Example #19
0
 /**
  * Get the route information for a given route.
  *
  * @param \Illuminate\Routing\Route $route
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     return $this->filterRoute(array('host' => $route->domain(), 'uri' => implode('|', $route->methods()) . ' ' . $route->uri(), 'name' => $route->getName(), 'action' => $route->getActionName(), 'version' => implode(', ', array_get($route->getAction(), 'version')), 'protected' => array_get($route->getAction(), 'protected') ? 'Yes' : 'No', 'scopes' => $this->getScopes($route)));
 }
 /**
  * @param Route                $route
  * @param EntrustUserInterface $user
  * @return bool
  */
 public function checkPermission(Route $route, EntrustUserInterface $user)
 {
     $action = $route->getName() ?: $route->getPath();
     return $this->canAccess($action, $user);
 }
 /**
  * @param Route $route
  *
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     return ['method' => implode('|', $route->methods()), 'uri' => $route->uri(), 'name' => $route->getName(), 'action' => $route->getActionName()];
 }
Example #22
0
 /**
  * Get the route information for a given route.
  *
  * @param  string  $name
  * @param  \Symfony\Component\Routing\Route  $route
  * @return array
  */
 protected function getRouteInformation($name, Route $route)
 {
     $uri = head($route->methods()) . ' ' . $route->uri();
     return array('host' => (string) $route->domain(), 'method' => (string) $this->getMethod($uri), 'uri' => (string) $uri, 'name' => (string) $route->getName(), 'action' => (string) $route->getActionName(), 'before' => (string) $this->getBeforeFilters($route), 'after' => (string) $this->getAfterFilters($route));
 }
 /**
  * Get the route information for a given route.
  *
  * @param \Illuminate\Routing\Route $route        	
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     return $this->filterRoute(['host' => $route->domain(), 'method' => implode('|', $route->methods()), 'uri' => $route->uri(), 'name' => $route->getName(), 'action' => $route->getActionName(), 'middleware' => $this->getMiddleware($route)]);
 }
 /**
  * Get the route information for a given route.
  *
  * @param \Illuminate\Routing\Route $route
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     if ($route->getName()) {
         return ['uri' => $route->uri(), 'name' => $route->getName(), 'before' => $this->getBeforeFilters($route)];
     }
     return null;
 }
Example #25
0
 /**
  * Create a new exception for missing route parameters.
  *
  * @param  \Illuminate\Routing\Route $route
  * @return static
  */
 public static function forMissingParameters($route)
 {
     return new static("Missing required parameters for [Route: {$route->getName()}] [URI: {$route->getPath()}].");
 }
 protected function getRouteInformation(Route $route, $current)
 {
     $uri = implode(' | ', $route->methods()) . ' <a href="' . $this->url->to($route->uri()) . '">' . $route->uri() . '</a>';
     return array('current' => $current == $route, 'host' => $route->domain(), 'uri' => $uri, 'name' => $route->getName(), 'action' => $route->getActionName(), 'before' => $this->getBeforeFilters($route), 'after' => $this->getAfterFilters($route));
 }
Example #27
0
 public function rightsFilter($user, \Illuminate\Routing\Route $route)
 {
     $this->action = $route->getName();
     return Permission::check($user, $this->action, Route::current()->parameters());
 }
Example #28
0
 /**
  * @return array
  */
 public function toArray()
 {
     return array_merge(['name' => $this->route->getName(), 'methods' => $this->route->getMethods(), 'domain' => $this->route->domain(), 'path' => $this->preparePath(), 'action' => $this->route->getAction(), 'wheres' => $this->extractWheres(), 'errors' => $this->errors], $this->getMeta(), $this->options);
 }
Example #29
0
 /**
  * Get the route information for a given route.
  *
  * @param  string  $name
  * @param  \Illuminate\Routing\Route  $route
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     $uri = implode('|', $route->methods()) . ' ' . $route->uri();
     return $this->filterRoute(array('host' => $route->domain(), 'uri' => $uri, 'name' => $route->getName(), 'action' => $route->getActionName(), 'before' => $this->getBeforeFilters($route), 'after' => $this->getAfterFilters($route)));
 }
Example #30
0
 /**
  * Get the route information for a given route.
  *
  * @param  \Illuminate\Routing\Route $route
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     return $this->filterRoute(['uri' => $route->uri(), 'methods' => $route->methods(), 'name' => $route->getName(), 'action' => $route->getActionName()]);
 }