本文整理汇总了PHP中Illuminate\Support\Facades\Route::currentRouteAction方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::currentRouteAction方法的具体用法?PHP Route::currentRouteAction怎么用?PHP Route::currentRouteAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Route
的用法示例。
在下文中一共展示了Route::currentRouteAction方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
public function test(Request $request)
{
// $user = User::find(1);
//
// if($user->hasRole('Founder')){
// return '您是创始人'.'ID:'.$user->id;
// };
if ($request->user()) {
// $userRoles = $request->user()->roles()->get();
// foreach($userRoles as $r){
// $roles[] = $r->name;
// }
// var_dump($roles);
$userRoles = Role::all();
foreach ($userRoles as $r) {
$roles[] = $r->name;
}
if (!$request->user()->hasRole($roles)) {
return redirect()->guest('auth/login');
}
//$can = Route::currentRouteName();//当前route-name exp:user.test
$can = Route::currentRouteAction();
echo $can;
$res = $request->user()->can($can);
echo $res;
}
}
示例2: LngCompose
public function LngCompose($view)
{
$arrLng = Languages::all()->toArray();
$action = Route::currentRouteAction();
$params = Route::getCurrentRoute()->parameters();
$arrAction = explode("\\", $action);
$controller = array_pop($arrAction);
$view->with(compact('arrLng', 'action', 'controller', 'params'));
}
示例3: lian
public function lian()
{
echo "MoooController/lian";
echo "<hr>";
$url = route('lian');
var_dump($url);
$action = Route::currentRouteAction();
var_dump($action);
}
示例4: initialize
/**
* Initialize Laravel-MultiAlerts.
*
* @param array $routes
* @param string $namespace
* @return $this
*/
public function initialize($routes, $namespace = '')
{
$this->routes = $routes;
$configKey = sprintf('gsmeira.routetracker.namespaces.%s', $namespace);
$this->namespace = config($configKey, 'App\\Http\\Controllers');
$this->currentAction = trim(str_replace($this->namespace, '', Route::currentRouteAction()), '\\');
if (strpos($this->currentAction, '@') !== false) {
list($this->currentController, $this->currentMethod) = explode('@', $this->currentAction);
}
$this->isCurrent = $this->hasCurrent($routes);
return $this;
}
示例5: check
public function check($controller_suffix = 'Controller')
{
$routeAction = Route::currentRouteAction();
preg_match_all('/([a-z0-9A-Z]+\\\\)?(\\w+)@(\\w+)/', $routeAction, $matchs);
$controller_full = $matchs[2][0];
//类名
$controller = str_replace($controller_suffix, '', $controller_full);
$action = $matchs[3][0];
//方法名
//不需要认证的模块,则放行
if (isset($this->config['AUTH_LOGIN_NO'][$controller]) && ($this->config['AUTH_LOGIN_NO'][$controller] == '*' || in_array($action, $this->config['AUTH_LOGIN_NO'][$controller]))) {
return true;
}
//没有登陆跳转到登陆页面
if (!$this->checkLogin()) {
//todo
return $this->noLogin();
}
$power = $this->getRolePower(Session::get($this->config['AUTH_SESSION_PREFIX'] . 'role_id'));
//临时的,记得删除-1 todo
//$power = -1;
if ($power == -1) {
return true;
} else {
$privilege = Lang::has('privilege') ? Lang::get('privilege') : array();
$controller = str_replace('Controller', '', $controller);
if ($privilege) {
if (isset($privilege[$controller]['power_rule']['module_hidden'])) {
if ($privilege[$controller]['power_rule']['module_hidden'] == 0) {
if (isset($privilege[$controller][$action])) {
if (isset($privilege[$controller]['power_rule'][$action]) && $privilege[$controller]['power_rule'][$action] == 1) {
return true;
} else {
if (isset($power[$controller][$action]) && $power[$controller][$action] == -1) {
return true;
}
}
} else {
//没有设置$privilege[$controller][$action]一律通过
return true;
}
} elseif ($privilege[$controller]['power_rule']['module_hidden'] == 1) {
return true;
}
}
}
}
return $this->noPower();
}
示例6: __construct
public function __construct()
{
LogR::register(last(explode('\\', get_class($this))) . ' ' . explode('@', Route::currentRouteAction())[1]);
}
示例7:
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">
<strong>Systeem</strong>
示例8: currentControllerAction
/**
* Returns the current controller actions method name.
*
* @param string $method
*
* @return string
*/
function currentControllerAction($method)
{
$class = explode('@', Route::currentRouteAction());
return sprintf('%s@%s', $class[0], $method);
}