本文整理汇总了PHP中Permissions::hasPermission方法的典型用法代码示例。如果您正苦于以下问题:PHP Permissions::hasPermission方法的具体用法?PHP Permissions::hasPermission怎么用?PHP Permissions::hasPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permissions
的用法示例。
在下文中一共展示了Permissions::hasPermission方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public static function get($route)
{
if (strpos($route, '/') !== false) {
list($folder, $route) = explode('/', $route);
}
if (strpos($route, ':') !== false) {
list($controller, $method) = explode(':', $route);
} else {
$controller = $route;
$method = 'index';
}
$controller = ucfirst($controller) . 'Controller';
$admin = isset($folder) && $folder == 'admin' ? true : false;
$user = self::$app['session']->get('user');
if ($admin) {
if (!$user || !Permissions::hasPermission('ACCESS_ADMIN')) {
return self::$app->redirect('/');
}
}
$path = (isset($folder) ? 'Controller\\' . ucfirst($folder) . '\\' : 'Controller\\') . $controller;
if (!class_exists($path)) {
throw new \Exception($controller . ' does not exist in ' . $path);
}
$controller = new $path(self::$app);
$params = func_get_args();
array_shift($params);
return call_user_func_array(array($controller, $method), $params);
}
示例2: trans
}
if ($path == "customer/tickets" && $blocking->should_block_tickets) {
return trans('msgs.you_dont_have_tickets_access');
}
}
}
});
Route::filter('has_permission', function ($route, $request, $permission) {
if (Auth::check()) {
if (!\KodeInfo\Utilities\Utils::canViewBackend(Auth::user()->id)) {
Auth::logout();
Session::flush();
Session::flash('error_msg', trans('msgs.access_denied_escalate_rights'));
return Redirect::to('/login');
}
if (!Permissions::hasPermission($permission)) {
$permission_obj = Permissions::where('key', $permission)->pluck('text');
Session::flash('error_msg', trans('msgs.access_denied_escalate_rights', ['permission_obj' => $permission_obj]));
return Redirect::to('/dashboard');
}
} else {
Session::flash('error_msg', trans('msgs.please_login_to_continue'));
return Redirect::to('/login');
}
});
Route::filter('backend', function () {
if (Auth::check()) {
if (!\KodeInfo\Utilities\Utils::canViewBackend(Auth::user()->id)) {
Auth::logout();
Session::flush();
Session::flash('error_msg', trans('msgs.access_denied_escalate_rights'));
示例3: hasAnyBlockingPermissions
static function hasAnyBlockingPermissions()
{
if (Permissions::hasPermission('blocking.block') || Permissions::hasPermission('blocking.all') || Permissions::hasPermission('blocking.delete')) {
return true;
} else {
return false;
}
}