本文整理汇总了PHP中Illuminate\Routing\Route::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::getName方法的具体用法?PHP Route::getName怎么用?PHP Route::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Routing\Route
的用法示例。
在下文中一共展示了Route::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: link
/**
* 메뉴의 링크를 생성하여 반환한다. 메뉴에 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이어야 합니다.');
}
示例2: filterRouteAsClass
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;
}
示例3: hasToBeAuthorized
/**
* 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();
}
示例4: getRouteInformation
/**
* 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');
}
示例5: link
/**
* 메뉴의 링크를 생성하여 반환한다. 메뉴에 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();
}
示例6: rules
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;
}
示例7: setupDefaults
/**
* @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;
}
示例8: generateTableRow
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;
}
示例9: route
/**
* 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;
}
示例10: addWhereClausesToRoute
/**
* 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);
}
示例11: checkRoutePattern
/**
* 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;
}
示例12: hasAccess
/**
* 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'));
}
}
示例13: setPageType
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);
}
示例14: edit
/**
* 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'));
}
示例15: parseRoute
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];
}
});
}