本文整理汇总了PHP中Illuminate\Support\Facades\Request::path方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::path方法的具体用法?PHP Request::path怎么用?PHP Request::path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Request
的用法示例。
在下文中一共展示了Request::path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* @param array $parameters
*
* @return string
*/
public static function render(array $parameters)
{
list($sortColumn, $sortParameter, $title, $queryParameters) = self::parseParameters($parameters);
$title = self::applyFormatting($title);
$icon = Config::get('columnsortable.default_icon_set');
foreach (Config::get('columnsortable.columns') as $value) {
if (in_array($sortColumn, $value['rows'])) {
$icon = $value['class'];
}
}
if (Request::get('sort') == $sortParameter && in_array(Request::get('order'), ['asc', 'desc'])) {
$icon .= Request::get('order') === 'asc' ? Config::get('columnsortable.asc_suffix', '-asc') : Config::get('columnsortable.desc_suffix', '-desc');
$direction = Request::get('order') === 'desc' ? 'asc' : 'desc';
} else {
$icon = Config::get('columnsortable.sortable_icon');
$direction = Config::get('columnsortable.default_direction_unsorted', 'asc');
}
$iconAndTextSeparator = Config::get('columnsortable.icon_text_separator', '');
$clickableIcon = Config::get('columnsortable.clickable_icon', false);
$trailingTag = $iconAndTextSeparator . '<i class="' . $icon . '"></i>' . '</a>';
if ($clickableIcon === false) {
$trailingTag = '</a>' . $iconAndTextSeparator . '<i class="' . $icon . '"></i>';
}
$anchorClass = self::getAnchorClass();
$queryString = http_build_query(array_merge($queryParameters, array_filter(Request::except('sort', 'order', 'page')), ['sort' => $sortParameter, 'order' => $direction]));
return '<a' . $anchorClass . ' href="' . url(Request::path() . '?' . $queryString) . '"' . '>' . htmlentities($title) . $trailingTag;
}
示例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: register
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app['router']->before(function ($request) {
// First clear out all "old" visitors
Visitor::clear();
$page = Request::path();
$ignore = Config::get('visitor-log::ignore');
if (is_array($ignore) && in_array($page, $ignore)) {
//We ignore this site
return;
}
$visitor = Visitor::getCurrent();
if (!$visitor) {
//We need to add a new user
$visitor = new Visitor();
$visitor->ip = Request::getClientIp();
$visitor->useragent = Request::server('HTTP_USER_AGENT');
$visitor->sid = str_random(25);
}
$user = null;
$usermodel = strtolower(Config::get('visitor-log::usermodel'));
if (($usermodel == "auth" || $usermodel == "laravel") && Auth::check()) {
$user = Auth::user()->id;
}
if ($usermodel == "sentry" && class_exists('Cartalyst\\Sentry\\SentryServiceProvider') && Sentry::check()) {
$user = Sentry::getUser()->id;
}
//Save/Update the rest
$visitor->user = $user;
$visitor->page = $page;
$visitor->save();
});
}
示例4: auth
/**
* Ensure user is logged in
*
* @return
*/
public function auth()
{
if (!$this->auth->check()) {
$redirect = '?redirect=' . urlencode(Request::path());
return Redirect::to('/auth/login' . $redirect)->with('error_message', Lang::get('messages.login_access_denied'));
}
}
示例5: register
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$configPath = __DIR__ . '/../config/sql-logging.php';
$this->mergeConfigFrom($configPath, 'sql-logging');
if (config('sql-logging.log', false)) {
Event::listen('illuminate.query', function ($query, $bindings, $time) {
$data = compact('bindings', 'time');
// Format binding data for sql insertion
foreach ($bindings as $i => $binding) {
if ($binding instanceof \DateTime) {
$bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
} else {
if (is_string($binding)) {
$bindings[$i] = "'{$binding}'";
}
}
}
// Insert bindings into query
$query = str_replace(array('%', '?'), array('%%', '%s'), $query);
$query = vsprintf($query, $bindings);
$log = new Logger('sql');
$log->pushHandler(new StreamHandler(storage_path() . '/logs/sql-' . date('Y-m-d') . '.log', Logger::INFO));
// if log request data
if (config('sql-logging.log_request', false)) {
$data['request_path'] = Request::path();
$data['request_method'] = Request::method();
$data['request_data'] = Request::all();
}
// add records to the log
$log->addInfo($query, $data);
});
}
}
示例6: hasAccess
private function hasAccess()
{
$patterns_quoted = preg_quote($this->block->exception, '/');
$to_replace = ['/(\\r\\n?|\\n)/', '/\\\\\\*/'];
$replacements = ['|', '.*'];
$regexpPatter = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/';
return (bool) preg_match($regexpPatter, Request::path());
return true;
}
示例7: active
/**
* Permet d'ajouter la classe active en fonction de la route
* @param $path
* @return bool|string
*/
function active($path)
{
$request = \Illuminate\Support\Facades\Request::path();
$match = $request === '/' ? '/' : explode('/', $request)[0];
if ($match === $path) {
return "class='active'";
}
return false;
}
示例8: item
private function item(&$item)
{
$tpm = array_search(Request::path(), array_column($item['sub'], 'route'));
if ($tpm !== false) {
$item['active'] = 'active open';
$item['open'] = 'open';
$item['display'] = 'block';
$item['sub'][$tpm]['active'] = 'active';
}
}
示例9: getHtmlCss
public function getHtmlCss($cssfiles)
{
$files = is_array($cssfiles) ? $cssfiles : func_get_args();
$cacheKey = CssKeys::getSingleKey(Request::path());
if (Cache::has($cacheKey)) {
$cssoutput = Cache::get($cacheKey);
return $this->getAsyncStylesheet($cssoutput, $files);
} else {
return $this->getStylesheetLink($files);
}
}
示例10: link
/**
* @param string $url
* @param string $name
* @param string $position
* @param array $attributes
*
* @return $this
*/
public function link($url, $name, $position = "BL", $attributes = array())
{
$match_url = trim(parse_url($url, PHP_URL_PATH), '/');
if (Request::path() != $match_url) {
$url = Persistence::get($match_url, parse_url($url, PHP_URL_QUERY));
}
$attributes = array_merge(array("class" => "btn btn-default"), $attributes);
$this->button_container[$position][] = HTML::link($url, $name, $attributes);
$this->links[] = $url;
return $this;
}
示例11: isActiveUrl
function isActiveUrl($path, $output = 'active')
{
if ($path !== '/') {
// not a frontpage
$path = trim($path, '/');
}
$actualPath = \Illuminate\Support\Facades\Request::path();
if (strpos($actualPath, $path) !== false) {
return $output;
}
}
示例12: link
/**
* @param string $url
* @param string $name
* @param string $position
* @param array $attributes
*
* @return $this
*/
public function link($url, $name, $position = "BL", $attributes = array())
{
$base = str_replace(Request::path(), '', strtok(Request::fullUrl(), '?'));
$match_url = str_replace($base, '/', strtok($url, '?'));
if (Request::path() != $match_url) {
$url = Persistence::get($match_url, parse_url($url, PHP_URL_QUERY));
}
$attributes = array_merge(array("class" => "btn btn-default"), $attributes);
$this->button_container[$position][] = HTML::link($url, $name, $attributes);
$this->links[] = $url;
return $this;
}
示例13: getPageBySlug
/**
* @return mixed
*/
private function getPageBySlug()
{
$path = Request::path();
//ie whatever/subpage/and-so-on
$slugs = explode("/", $path);
$first_slug = $slugs['0'];
$last_slug = $slugs[count($slugs) - 1];
$slug = $last_slug;
//Page by Slug
$page = Page::with("content")->published()->where('slug', '=', $slug)->first();
return $page;
}
示例14: parseRequestDetails
public function parseRequestDetails()
{
$result = ['action' => 'index', 'arguments' => []];
$thisPath = urlbuilder($this->getUrl())->path();
$requestUrl = urlbuilder(RequestFacade::path())->shift($thisPath);
if (count($requestUrl->segments()) == 0) {
return $result;
}
$result['action'] = $requestUrl->shiftSegment();
$result['arguments'] = $requestUrl->segments();
return $result;
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
session(['path' => Request::path()]);
return redirect(route('getLogin'));
}
}
return $next($request);
}