本文整理汇总了PHP中Illuminate\Support\Facades\Request::segments方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::segments方法的具体用法?PHP Request::segments怎么用?PHP Request::segments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Request
的用法示例。
在下文中一共展示了Request::segments方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getObject
/**
* @return Model
*/
public function getObject()
{
// Get ID from url segments.
$segments = Request::segments();
$id = end($segments);
return $this->getQuerySet()->where($this->lookupField, $id)->firstOrFail();
}
示例2: model
public static function model($url = null)
{
static::start();
$stage = static::getRequestedStage();
$key = $url . '|' . $stage;
if (isset(static::$models[$key])) {
return static::$models[$key];
}
$segments = !is_null($url) ? static::segments($url) : Request::segments();
$segment = array_shift($segments);
if ($segment) {
$parentID = 0;
do {
$model = \SiteTree::get()->filter(array('URLSegment' => $segment, 'ParentID' => $parentID))->First();
if ($model) {
$parentID = $model->ID;
} else {
break;
}
} while ($segment = array_shift($segments));
} else {
// special case - home page
$model = \SiteTree::get()->filter(array('URLSegment' => 'home', 'ParentID' => 0))->First();
}
return static::$models[$url] = $model;
}
示例3: getApiPrefix
/**
* Figure out the api prefix base on incoming request.
*
* @return string
*/
public function getApiPrefix()
{
$prefix = '';
$api_versions = Config::get('andizzle/rest-framework::deprecated') ?: array();
array_push($api_versions, Config::get('andizzle/rest-framework::version'));
$segments = Request::segments();
foreach ($segments as $segment) {
$prefix .= '/' . $segment;
if (in_array($segment, $api_versions)) {
break;
}
}
return $prefix;
}
示例4: __construct
public function __construct(PhpEngine $engine)
{
$this->storage = storage_path() . '/views';
if (count(Input::query()) > 0) {
$input = http_build_query(Input::query());
} else {
$input = NULL;
}
$this->engine = $engine;
$segments = Request::segments();
if (count($segments) > 0) {
$segments = implode('.', $segments);
} else {
$segments = "";
}
$this->filename = $this->pfx . md5(\URL::to('/') . $segments . '?' . $input);
}
示例5: isBackend
public function isBackend()
{
return head(Request::segments()) == config('adminpanel.base_url', 'adminpanel');
}
示例6:
</head>
<body>
<div class="container">
{{-- Block for displaying the menu --}}
<div class="row" id="system_menu">
@include('_templates.system-menu')
</div>
<div class="row" id="menu">
<?php
use Illuminate\Support\Facades\Request;
use picaBase\Facades\Menu;
// Displaying menu
echo Menu::showMenu(Request::segments());
?>
<div class="pull-right">
<img src="images/under-construction.gif">
</div>
</div>
{{-- Block for displaying status- and errormessages --}}
<div class="row" id="user_messages">
@if (count($errors) > 0)
<div class="alert alert-danger col-md-6 col-md-offset-3">
<p>@lang('pica.error_intro')</p>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
示例7: getRelatedMethod
/**
*
* ---- RELATIONS ----
*
*/
private function getRelatedMethod()
{
$requestSegments = Request::segments();
if (count($requestSegments) >= 3) {
return array_pop($requestSegments);
}
return null;
}
示例8: getState
protected function getState()
{
$rsegments_array = Request::segments();
if (isset($rsegments_array[2]) && is_numeric($rsegments_array[2])) {
$upload_url = site_url($rsegments_array[0] . '/' . $rsegments_array[1] . '/upload_file/' . $rsegments_array[2]);
$ajax_list_url = site_url($rsegments_array[0] . '/' . $rsegments_array[1] . '/' . $rsegments_array[2] . '/ajax_list');
$ordering_url = site_url($rsegments_array[0] . '/' . $rsegments_array[1] . '/ordering');
$insert_title_url = site_url($rsegments_array[0] . '/' . $rsegments_array[1] . '/insert_title');
$state = array('name' => 'list', 'upload_url' => $upload_url, 'relation_value' => $rsegments_array[2]);
$state['ajax'] = isset($rsegments_array[3]) && $rsegments_array[3] == 'ajax_list' ? true : false;
$state['ajax_list_url'] = $ajax_list_url;
$state['ordering_url'] = $ordering_url;
$state['insert_title_url'] = $insert_title_url;
return (object) $state;
} elseif (empty($rsegments_array[2]) && empty($this->relation_field) || !empty($rsegments_array[2]) && $rsegments_array[2] == 'ajax_list') {
$upload_url = site_url($rsegments_array[0] . '/' . $rsegments_array[1] . '/upload_file');
$ajax_list_url = site_url($rsegments_array[0] . '/' . $rsegments_array[1] . '/ajax_list');
$ordering_url = site_url($rsegments_array[0] . '/' . $rsegments_array[1] . '/ordering');
$insert_title_url = site_url($rsegments_array[0] . '/' . $rsegments_array[1] . '/insert_title');
$state = array('name' => 'list', 'upload_url' => $upload_url);
$state['ajax'] = isset($rsegments_array[2]) && $rsegments_array[2] == 'ajax_list' ? true : false;
$state['ajax_list_url'] = $ajax_list_url;
$state['ordering_url'] = $ordering_url;
$state['insert_title_url'] = $insert_title_url;
return (object) $state;
} elseif (isset($rsegments_array[2]) && $rsegments_array[2] == 'upload_file') {
#region Just rename my file
$new_file_name = '';
//$old_file_name = $this->_to_greeklish($_GET['qqfile']);
$old_file_name = $this->_convert_foreign_characters($_GET['qqfile']);
$max = strlen($old_file_name);
for ($i = 0; $i < $max; $i++) {
$numMatches = preg_match('/^[A-Za-z0-9.-_]+$/', $old_file_name[$i], $matches);
if ($numMatches > 0) {
$new_file_name .= strtolower($old_file_name[$i]);
} else {
$new_file_name .= '-';
}
}
$file_name = substr(substr(uniqid(), 9, 13) . '-' . $new_file_name, 0, 100);
#endregion
$results = array('name' => 'upload_file', 'file_name' => $file_name);
if (isset($rsegments_array[3]) && is_numeric($rsegments_array[3])) {
$results['relation_value'] = $rsegments_array[3];
}
return (object) $results;
} elseif (isset($rsegments_array[2]) && isset($rsegments_array[3]) && $rsegments_array[2] == 'delete_file' && is_numeric($rsegments_array[3])) {
$state = array('name' => 'delete_file', 'id' => $rsegments_array[3]);
return (object) $state;
} elseif (isset($rsegments_array[2]) && $rsegments_array[2] == 'ordering') {
$state = array('name' => 'ordering');
return (object) $state;
} elseif (isset($rsegments_array[2]) && $rsegments_array[2] == 'insert_title') {
$state = array('name' => 'insert_title');
return (object) $state;
}
}
示例9: __construct
public function __construct()
{
$this->locale = App::getLocale();
$this->route_segments = Request::segments();
}
示例10: getTableLinks
/**
* Create Table Links
*
* @return string
*/
public function getTableLinks()
{
$segments = Request::segments();
if (!in_array('trashed', $segments)) {
return implode(' ', [$this->getViewLink(), $this->getEditLInk(), $this->getDeleteLink()]);
} else {
return implode(' ', [$this->getRestoreLink(), $this->getDestroyLink()]);
}
}