本文整理汇总了PHP中Illuminate\Support\Facades\Route::currentRouteName方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::currentRouteName方法的具体用法?PHP Route::currentRouteName怎么用?PHP Route::currentRouteName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Route
的用法示例。
在下文中一共展示了Route::currentRouteName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadPageTitle
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: compose
/**
* 将数据绑定到视图。
*
* @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: track
/**
* 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: handle
/**
* 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: compose
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'));
}
示例6: handle
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: areActiveRoutes
static function areActiveRoutes(array $routes, $output = "active")
{
foreach ($routes as $route) {
if (Route::currentRouteName() == $route) {
return $output;
}
}
}
示例8: areRoutes
/**
* ### Ç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;
}
示例9: listagem
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: addUser
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());
}
示例11: index
/**
* 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: isActive
/**
* 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;
}
}
示例13: edit
/**
* 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: getAvatarAttribute
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: link_to_sorting_action
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' ? '↑' : '↓' : 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);
}