本文整理汇总了PHP中Illuminate\Http\Request::route方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::route方法的具体用法?PHP Request::route怎么用?PHP Request::route使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Http\Request
的用法示例。
在下文中一共展示了Request::route方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Detect the active module and setup our
* environment with it.
*/
public function handle()
{
/**
* In order to detect we MUST have a route
* and we MUST have a namespace in the
* streams::addon action parameter.
*
* @var Route $route
*/
$route = $this->request->route();
/* @var Module $module */
if ($route && ($module = $this->modules->get(array_get($route->getAction(), 'streams::addon')))) {
$module->setActive(true);
}
if (!$module && $this->request->segment(1) == 'admin' && ($module = $this->modules->findBySlug($this->request->segment(2)))) {
$module->setActive(true);
}
if (!$module) {
return;
}
$this->container->make('view')->addNamespace('module', $module->getPath('resources/views'));
$this->container->make('translator')->addNamespace('module', $module->getPath('resources/lang'));
$this->asset->addPath('module', $module->getPath('resources'));
$this->image->addPath('module', $module->getPath('resources'));
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
$owner = $creator = null;
/** @var TenantContract $tenant */
$tenant = app('auth.tenant');
/** @var TenantParticipantContract $owner */
if (null !== ($tenantOwnerId = $request->route('tenant_owner_id'))) {
if ($tenant->getTenantOwnerId() && $tenantOwnerId != $tenant->getTenantOwnerId()) {
abort(500, sprintf('Selected tenant_owner_id "%s" in route parameters does not match the resolved owner "%s: %s"', $tenantOwnerId, $tenant->getTenantOwnerId(), $tenant->getTenantOwner()->getName()));
}
$owner = $this->repository->find($tenantOwnerId);
}
/** @var TenantParticipantContract $creator */
if (null !== ($tenantCreatorId = $request->route('tenant_creator_id'))) {
$creator = $this->repository->find($tenantCreatorId);
}
/** @var BelongsToTenantContract $user */
$user = $this->auth->user();
if (!$user instanceof BelongsToTenantContract) {
abort(500, sprintf('The Authenticatable User entity does not implement BelongsToTenant contract.'));
}
if (!$creator || !$user->belongsToTenant($creator)) {
return redirect()->route('tenant.access_denied');
}
if ($owner && $creator->getTenantOwner() !== $owner) {
return redirect()->route('tenant.invalid_tenant_hierarchy');
}
// remove the tenant parameters, TenantAware URL generator has access to Tenant
$request->route()->forgetParameter('tenant_owner_id');
$request->route()->forgetParameter('tenant_creator_id');
// bind resolved tenant data to container
$tenant->updateTenancy($user, $creator->getTenantOwner(), $creator);
return $next($request);
}
示例3: handle
/**
* Allow the request to proceed if the user is allowed
*
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if ($request->route()->getName() && $this->check->can($request->route()->getName())) {
return $next($request);
}
abort(403);
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
$uri = $request->route()->getParameter('location');
$page = Page::findByUri($uri);
if (!$page) {
$url = URL::findByLocation($uri);
// The URL isn't in use or
// The URL is in use and has a page - the page must not be visible to the current user
//
// 404.
if (!$url || !$url->getPage()->isVisible()) {
throw new NotFoundHttpException();
}
// The url is in use but doesn't have a page.
// The page must have been deleted.
//
// 410.
throw new GoneHttpException();
}
if (Editor::isDisabled() && !$page->isVisible()) {
throw new NotFoundHttpException();
}
if (!$page->url()->is($uri)) {
return redirect((string) $page->url(), 301);
}
$request->route()->setParameter('page', $page);
Editor::setActivePage($page);
View::share('page', $page);
return $next($request);
}
示例5: __construct
/**
* ApiDataPreview constructor.
*
* @param Request $request
*
* @internal param $id
*/
public function __construct(Request $request)
{
$this->model = $request->route('model');
$this->model = ucwords($this->model);
$this->NamespacedModel = '\\App\\' . $this->model;
$this->id = $request->route('id');
}
示例6: __construct
public function __construct(Request $request)
{
$this->request = $request;
$this->page = $request->route()->getParameter('page');
$this->url = $request->route()->getParameter('url');
$this->authorize('editUrls', $this->page);
}
示例7: __construct
/**
* SocialAuthController constructor.
* @param Request $request
*/
public function __construct(Request $request)
{
$this->request = $request;
//Provider
$provider = $this->request->route('provider');
//Provider Object
switch ($provider) {
case 'vkontakte':
$this->provider = new \Alexusmai\Admin\Controllers\Auth\VkontakteProvider('vkontakte');
break;
case 'odnoklassniki':
$this->provider = new \Alexusmai\Admin\Controllers\Auth\OdnoklassnikiProvider('odnoklassniki');
break;
case 'facebook':
$this->provider = new \Alexusmai\Admin\Controllers\Auth\FacebookProvider('facebook');
break;
case 'yandex':
$this->provider = new \Alexusmai\Admin\Controllers\Auth\YandexProvider('yandex');
break;
case 'google':
$this->provider = new \Alexusmai\Admin\Controllers\Auth\GoogleProvider('google');
break;
default:
abort(404);
}
}
示例8: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $param
* @return mixed
*/
public function handle(Request $request, Closure $next, $param = null)
{
$routeParamName = $param ? str_plural($param) : 'id';
if ($routeParamValue = $request->route()->getParameter($routeParamName)) {
$request->route()->setParameter($routeParamName, optimus()->decode($routeParamValue));
}
return $next($request);
}
示例9: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$category_id = $request->route('category_id') ? $request->route('category_id') : $request->input('category_id');
if (!$this->skill->skillCategoryExist($category_id)) {
return $this->json_response->forbidden();
}
return $next($request);
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$projectId = $request->route('id') ? $request->route('id') : $request->route('project');
if (!$this->service->checkProjectPermissions($projectId)) {
return ['code' => 403, 'error' => 'You haven\'t permission to access project'];
}
return $next($request);
}
示例11: getRouteParameter
/**
* Get the value of the given route parameter.
*
* @param string $key
* @return string
*/
protected function getRouteParameter($key)
{
$route = $this->request->route();
$route = end($route);
if (isset($route[$key])) {
return $route[$key];
}
}
示例12: handle
/**
* Handle an incoming request.
*
* @param Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
$projectId = $request->route("id") ? $request->route("id") : $request->route("project");
if ($this->service->checkProjectOwner($projectId) == false && $this->service->checkProjectPermissions($projectId) == false) {
return response(['message' => 'User don\'t have access to project'], 403);
}
return $next($request);
}
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$projectId = $request->route('id') ?: $request->route('project');
if ($this->service->checkProjectPermissions($projectId) == false) {
return response('Unauthorized.', 403);
}
return $next($request);
}
示例14: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$projectId = $request->route('id') ? $request->route('id') : $request->route('project');
if ($this->service->checkProjectOwner($projectId) == false) {
return ['error' => 'Access forbiden'];
}
return $next($request);
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$projetoId = $request->route('id') ? $request->route('id') : $request->route('projetos');
if ($this->service->checkProjetoOwner($projetoId) == false) {
return ['error' => 'You haven\'t permission to accesses projeto'];
}
return $next($request);
}