本文整理汇总了PHP中Illuminate\Support\Facades\Request::route方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::route方法的具体用法?PHP Request::route怎么用?PHP Request::route使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Request
的用法示例。
在下文中一共展示了Request::route方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateSignedURL
public function validateSignedURL($actual_url, $signed_url, $substitions)
{
$current_route = Request::route();
$current_route_name = $current_route->getName();
if (isset($substitions[$current_route_name])) {
$substition = $substitions[$current_route_name];
// make sure the host of the signed URL matches the host of the substitution URL
if (isset($substition['host'])) {
$signed_host = $this->getHostFromURL($signed_url);
$allowed_host = $substition['host'];
if ($signed_host != $allowed_host) {
Log::debug("HOST MISMATCH: \$signed_host={$signed_host} \$allowed_host={$allowed_host}");
// no host match - return false
return false;
}
}
// check the route
$substitute_route = new Route($current_route->getMethods(), $substition['route'], []);
$signed_request = \Illuminate\Http\Request::create($signed_url, Request::method());
if ($substitute_route->matches($signed_request)) {
// the allowed substitute route matches the signed request
return true;
}
Log::debug("ROUTE MISMATCH: pathinfo=" . json_encode(Request::getFacadeRoot()->getPathInfo()) . " allowed route={$substition['route']}");
}
// this signed URL was not valid
return false;
}
示例2: show
function show()
{
// dd(Page::all()->toArray());
$page = Page::orWhere(function ($query) {
$query->where('url', '=', Request::path());
})->orWhere(function ($query) {
$query->where('url', '=', '/' . Request::path());
})->orWhere(function ($query) {
$query->where('url', '=', Request::url());
})->orWhere(function ($query) {
$query->where('url', '=', Request::route()->getPath());
})->orWhere(function ($query) {
$query->where('url', '=', '/' . Request::route()->getPath());
})->get()->first();
$ps = Post::where('page_id', '=', $page->id)->orderBy('sort', 'ASC')->orderBy('id', 'ASC')->get();
$posts = [];
foreach ($page->template()->first()->sections() as $sec) {
$posts[$sec->name] = [];
}
foreach ($ps as $p) {
$posts[$p->section()->first()->name][] = $p;
}
$pages = [];
foreach (Page::all() as $pi) {
$pages[$pi->name] = $pi;
}
$fn = str_replace('.blade.php', '', $page->template()->first()->filename);
return View::make("aui/templates/" . $fn)->with('posts', $posts)->with('pages', $pages)->with('page', $page);
}
示例3: post
function post()
{
$att = Attachment::find(Request::route('id3'));
$pageId = Request::route('id1');
$att->delete();
return Redirect::to("/admin/manage-pages/{$pageId}/content");
}
示例4: post
function post()
{
$pageId = Request::route('id1');
$sectionId = Request::route('id2');
$section = Section::find($sectionId);
$inputs = $this->inputs();
$post = new Post();
$post->page_id = $pageId;
$post->section_id = $sectionId;
$post->name = $section->name;
$post->description = $section->description;
$post->save();
foreach ($inputs as $input) {
$item = Item::find($input->id);
$content = null;
if (isset($content) === false) {
$content = new Content();
$content->item_id = $item->id;
$content->post_id = $post->id;
$input->insert($content, Input::get("{$item->id}"));
}
// else {
// $input->update($content, Input::get("$item->id"));
// }
$content->save();
}
return Redirect::to("/admin/manage-pages/{$pageId}/content");
}
示例5: compose
/**
* Bind data to the view.
*
* @param View $view
*
* @return void
*/
public function compose(View $view)
{
$locale = app()->getLocale();
$filename = Request::route()->getName() . '.md';
$filepath = 'userhelp' . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $filename;
$help = Storage::exists($filepath) ? Markdown::convertToHtml(Storage::get($filepath)) : '';
$view->with('help', $help);
}
示例6: compose
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$wechatId = Request::route('wechatId');
if (Request::route('wechat')) {
$wechatId = Request::route('wechat');
}
$view->with('wechatId', $wechatId);
}
示例7: __construct
/**
* Class constructor
*/
public function __construct()
{
// Setting role based access
$permissions = ['role' => [config('larbac.role')]];
if (is_object(Request::route())) {
Request::route()->setParameter('larbac', $permissions);
$this->middleware('larbac');
}
}
示例8: handleException
/**
* Handles exceptions with redirect.
*
* @param Exception $exception
* @return Illuminate\Routing\Redirector
*/
public function handleException(Exception $exception)
{
// Get redirect
$referer = Request::header('referer');
$url = empty($referer) ? route('users.signin') : $referer;
// Add the fragment if defined on the route
$options = Request::route()->getAction();
$fragment = array_get($options, 'fragment');
$url = $fragment ? $url . '#' . $fragment : $url;
// Send redirect
return Redirect::to($url)->with('message', $exception->getMessage())->with('code', $exception->getCode())->withErrors($exception->getBag())->withInput();
}
示例9: apply
public function apply(Builder $builder, Model $model)
{
// Determine if there's a route to be had
if (!$model->getRoute() && Request::route() && Request::route()->getName()) {
// Set the route for the model
$model->setRoute(Request::route()->getName());
}
// Get the scope on the current route
$scope = Check::getRole()->scope($model->getRoute());
// Check if the model has the necessary scope
if ($scope && Base::getModelMethod('restrict', $scope, $model)) {
return $model->{Base::getModelMethod('restrict', $scope)}($builder);
}
return $builder;
}
示例10: response
/**
* Send output or error.
*
* @param $output
* @param $code
* @return mixed
*/
public static function response($output, $code)
{
if (Request::isMethod('get') && strpos(Request::route()->getName(), 'index') !== false) {
return Response::json($output, $code);
}
if (empty($output) || collect($output)->isEmpty()) {
if ($code === 304) {
return Response::json($output, $code);
}
return Response::json(self::error(64), 404);
}
if ($output === false or $output === 0) {
return Response::json(self::error(64), 404);
}
return Response::json($output, $code);
}
示例11: link
/**
* @param array $parameters
* @return string
*/
public static function link(array $parameters)
{
if (count($parameters) === 1) {
$parameters[1] = ucfirst($parameters[0]);
}
$col = $parameters[0];
$title = $parameters[1];
$icon = Config::get('columnsortable.sortable_icon');
foreach (Config::get('columnsortable.columns') as $key => $value) {
if (in_array($col, $value['rows'])) {
$icon = $value['class'];
}
}
if (Input::get('sort') == $col && in_array(Input::get('order'), ['asc', 'desc'])) {
$icon = $icon . '-' . Input::get('order');
} else {
$icon = Config::get('columnsortable.sortable_icon');
}
$parameters = ['sort' => $col, 'order' => Input::get('order') === 'asc' ? 'desc' : 'asc'];
$query_string = http_build_query(array_merge(Request::route()->parameters(), $parameters));
return '<a href="' . url(Request::path() . '?' . $query_string) . '"' . '>' . htmlentities($title) . '</a>' . ' ' . '<i class="' . $icon . '"></i>';
}
示例12: show
function show()
{
$page = Page::find(Request::route('id1'));
$views = [];
$views[] = (new HeadingItem())->label($page->name)->views([(new ButtonItem())->target('_blank')->label("Open Page")->defaultValue($page->url)]);
foreach ($page->template()->first()->sections()->get() as $sec) {
$secViews = [];
$header = "{$sec->name}";
$secButtons = [];
$icon = null;
foreach ($page->posts()->where('section_id', '=', $sec->id)->orderBy('sort', 'ASC')->orderBy('id', 'ASC')->get() as $post) {
$buttons = [];
$buttons[] = ["label" => 'Edit', "href" => "/admin/manage-pages/" . $page->id . "/posts/" . $post->id . "/edit"];
$buttons[] = ["label" => 'Delete', "href" => "/admin/manage-pages/" . $page->id . "/posts/" . $post->id . "/delete"];
if ($sec->single == 0) {
$secViews[] = ViewUtils::box($post->name_formatted, (new PageSummaryPostsForm())->postViews($post->id), null, null, true, $buttons, 'fa-angle-double-right');
} else {
$header = $post->section()->first()->name;
//$post->name_formatted." - ".
$secViews[] = ViewUtils::plain((new PageSummaryPostsForm())->postViews($post->id));
$secButtons[] = ["label" => 'Edit', "href" => "/admin/manage-pages/" . $page->id . "/posts/" . $post->id . "/edit"];
// $secButtons[] = ["label"=>'Delete', "href"=>"/admin/manage-pages/".$page->id."/posts/".$post->id."/delete"];
$icon = 'fa-angle-double-right';
}
}
if ($sec->single == 0) {
$secButtons[] = ["label" => 'Add Post', "href" => "/admin/manage-pages/" . $page->id . "/section/{$sec->id}/add-post"];
$secButtons[] = ["label" => 'Sort', "href" => "/admin/manage-pages/" . $page->id . "/section/{$sec->id}/sort"];
$icon = 'fa-bars';
} else {
if (count($secViews) === 0) {
$secButtons[] = ["label" => 'Create', "href" => "/admin/manage-pages/" . $page->id . "/section/{$sec->id}/add-post"];
}
}
$views[] = ViewUtils::box($header, $secViews, null, null, false, $secButtons, $icon);
}
// dd($page->posts()->first()->name);
return ViewUtils::page($views);
}
示例13: instantiateView
protected function instantiateView()
{
$route = \Illuminate\Support\Facades\Request::route()->getAction()['controller'];
$parts = explode('@', $route);
$controllerParts = explode('\\', $parts[0]);
$controllerName = array_pop($controllerParts);
$controller = str_slug(snake_case(substr($controllerName, 0, -strlen('Controller'))));
$action = str_slug(snake_case($parts[1]));
// Set up the view based on the module, controller, and action names.
$viewFile = "{$controller}.{$action}";
foreach (\Module::slugs() as $mod) {
if (view_exists("{$mod}::{$viewFile}")) {
$this->view = view("{$mod}::{$viewFile}");
}
}
if (!$this->view && view_exists($viewFile)) {
$this->view = view($viewFile);
} elseif (!$this->view) {
$this->view = view('base');
}
// Set up some more view variables.
$this->view->controller = $controller;
$this->view->action = $action;
$this->view->app_env = env('APP_ENV');
$this->view->app_version = config('app.version');
$this->view->app_title = config('app.title');
$this->view->site_name = config('app.site_name');
$this->view->scripts = [];
$this->view->return_to = substr(\Request::url(), strlen(url('')));
$this->user = Auth::user();
$this->view->user = $this->user;
$this->view->tab = 'schedule';
$this->view->alerts = \Session::get('alerts', array());
$this->view->modules = \Module::slugs();
$this->view->bing_key = env('BING_KEY');
}
示例14: compose
/**
* Bind data to the view.
*
* @param View $view
*
* @return void
*/
public function compose(View $view)
{
$view->with('business', session()->get('selected.business'));
$view->with('route', Request::route()->getName());
}
示例15: check_is_module
function check_is_module($namedroute)
{
return \Illuminate\Support\Facades\Request::route()->getName() == $namedroute ? 'active' : '';
}