本文整理汇总了PHP中Request::is方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::is方法的具体用法?PHP Request::is怎么用?PHP Request::is使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request::is方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Render an exception into an HTTP response.
*
* @param Request $request
* @param Exception $exception
*
* @return Response
*/
public function render($request, Exception $exception)
{
if (!$request->is(config('jsonapi.url'))) {
return parent::render($request, $exception);
}
return $this->handle($request, $exception);
}
示例2: __construct
/**
* Initializer.
*
* @access public
* @return BaseController
*/
public function __construct()
{
$is_admin = Request::is('admin*');
$is_backend = Request::is('backend*');
/* Set middleware(s) based on route URLs */
if ($is_admin || $is_backend) {
$this->middleware('auth');
if ($is_backend) {
// Backend specific middleware
$this->middleware('auth.backend');
}
$this->middleware('auth.permissions');
if (!Request::is('*users/change-password')) {
// No validation for stale password if password is being changed
$this->middleware('auth.pw_6_months');
}
}
list($this->link_type, $this->link, $this->layout, $this->current_theme) = current_section();
View::share('link_type', $this->link_type);
View::share('current_theme', $this->current_theme);
$website_settings = Setting::lists('value', 'name')->all();
View::share('website_settings', $website_settings);
$locale = Setting::value('language');
App::setLocale($locale);
Lang::setLocale($locale);
$this->user = current_user();
View::share('current_user', $this->user);
View::share('current_user_companies', current_user_companies());
}
示例3: set_active
/**
* Help in setting the class of the active link to 'active'
* If another class is required,
* pass a third parameter of class name
* @param $path
* @param string $secondPath
* @param string $active
* @return string
*/
function set_active($path, $secondPath = '', $active = 'active')
{
if ($path == 'admin/search' && strpos(Request::path(), 'admin/search') !== false) {
return $active;
}
return Request::is($path) || Request::is($secondPath) ? $active : '';
}
示例4: set_expanded
/**
* @param array $array
* @param string $active
* @return string
*/
function set_expanded($array = array(), $active = 'nav-expanded')
{
$path = Request::path();
if (in_array($path, $array)) {
return Request::is($path) ? $active : '';
}
}
示例5: showSocialShareTools
function showSocialShareTools()
{
if (!\Request::is('admin/*') && !\Request::is('blog/admin/*')) {
return true;
}
return false;
}
示例6: setActive
function setActive($path, $strict = false, $active = 'active')
{
if ($strict) {
return Request::is($path) ? $active : '';
}
return strpos(Request::path(), $path) !== false ? $active : '';
}
示例7: printMenu
public static function printMenu($menus, $class = null)
{
echo '<ul' . ($class ? ' class="' . $class . '"' : '') . '>';
foreach ($menus as $menu) {
if (!$menu['hide']) {
if (!array_key_exists('path', $menu)) {
echo '<li><span>' . \Lang::get('redminportal::menus.' . $menu['name']) . '</span>';
} else {
if ($menu['path'] == '') {
echo '<li><span>' . \Lang::get('redminportal::menus.' . $menu['name']) . '</span>';
} else {
if (\Request::is($menu['path']) or \Request::is($menu['path'] . '/*')) {
echo '<li class="active">';
} else {
echo '<li>';
}
echo '<a href="' . \URL::to($menu['path']) . '">' . \Lang::get('redminportal::menus.' . $menu['name']) . '</a>';
}
}
// If got children menu
if (array_key_exists('children', $menu)) {
RHelper::printMenu($menu['children']);
}
echo '</li>';
}
}
echo '</ul>';
}
示例8: build
/**
* Build a navigation menu from an array with the following structure: <br/>
* $navbar = array( <br/>
* ['url'=>'url', 'textkey'=>'public.title', 'nopattern' => true ], <br/>
* ['url'=>'url/products', 'textkey'=>'public.products.title' ], <br/>
* ['url'=>'url/clients', 'textkey'=>'public.clients.title', 'icon' => 'fa-users' ], <br/>
*);
*/
public static function build(array $_menu, $_currentLocale = '', $_addItemClass = '')
{
$str = '';
foreach ($_menu as $key => $option) {
$icon = isset($option['icon']) ? '<i class="fa ' . $option['icon'] . ' fa-fw"></i> ' : '';
if (isset($option['divider'])) {
$str .= '<li class="divider"></li>';
} else {
if (isset($option['submenu'])) {
$requestPattern = $_currentLocale . ($option['url'] == '' ? '' : '/' . $option['url'] . '*');
$isActive = '';
$isOpenned = '';
if (Request::is($requestPattern)) {
$isActive = ' active';
$isOpenned = ' in';
}
$str .= '<li class="' . $_addItemClass . ' list-toggle' . $isActive . '">' . '<a class="accordion-toggle" href="#collapse-' . $key . '" data-toggle="collapse">' . $icon . trans($option['textkey']) . '</a>' . '<ul id="collapse-' . $key . '" class="collapse' . $isOpenned . '">' . self::build($option['submenu'], $_currentLocale) . '</ul>' . '</li>';
} else {
$submenusPattern = isset($option['nopattern']) ? '' : '*';
$requestPattern = $_currentLocale . ($option['url'] == '' ? '' : '/' . $option['url'] . $submenusPattern);
//$requestPattern = $_currentLocale . $option['url'] . $submenusPattern;
$isActive = \Request::is($requestPattern) ? ' active' : '';
$str .= '<li class="' . $_addItemClass . $isActive . '">' . '<a href="' . \URL::to($option['url']) . '">' . $icon . trans($option['textkey']) . '</a>' . '</li>';
}
}
}
return $str;
}
示例9: show_nav
/**
* Generate a URL to a controller action.
*
* @param string $name
* @param array $parameters
* @param bool $absolute
* @return string
*/
function show_nav($url)
{
$className = '';
if ($url == Request::is('admin/post*') || $url == Request::is('admin/upload*')) {
$className = 'active';
}
return $className;
}
示例10: set_active
/**
* Set active class if request is in path.
*
* @param string $path
* @param array $classes
* @param string $active
*
* @return string
*/
function set_active($path, array $classes = [], $active = 'active')
{
if (Request::is($path)) {
$classes[] = $active;
}
$class = e(implode(' ', $classes));
return empty($classes) ? '' : "class=\"{$class}\"";
}
示例11: setBroadcasterActive
function setBroadcasterActive($path, $active = "active")
{
if ($path == "/") {
return URL::route('broadcasterHome') === URL::current() ? $active : "";
}
$path = "broadcaster" . $path;
return Request::is($path . '*') ? $active : "";
}
示例12: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = ['title' => 'required|min:3|max:100|unique:articles', 'body' => 'required', 'published_at' => 'required'];
if (\Request::is('article/*') && \Request::isMethod('PUT')) {
$rules['title'] = 'required|min:3|max:100|unique:articles,title,' . $this->article->id;
}
return $rules;
}
示例13: isInbox
public static function isInbox()
{
if (Request::is("m/message/f/inbox")) {
return true;
} else {
return false;
}
}
示例14: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if (FacadeRequest::is('accounts/create')) {
$response = ['first_name' => 'required|min:3', 'last_name' => 'required|min:3', 'email' => 'required|email|max:255', 'address' => 'required:min:5', 'city' => 'required:min:3', 'postal_code' => 'required:min:6', 'file' => 'required|image|mimes:jpg,jpeg,png,gif|max:900'];
} else {
$response = ['first_name' => 'required|min:3', 'last_name' => 'required|min:3', 'email' => 'required|email|max:255', 'address' => 'required:min:5', 'city' => 'required:min:3', 'postal_code' => 'required:min:6', 'file' => 'image|mimes:jpg,jpeg,png,gif|max:900'];
}
return $response;
}
示例15: is_current_model
/**
* 检查当前url是否属于菜单中定义的模式,完成菜单激活状态
*
* @param array $pattern app/config/menu.php中的pattern
*
* @return boolean
*/
function is_current_model(array $pattern)
{
foreach ($pattern as $ptn) {
if (Request::is($ptn)) {
return true;
}
}
return false;
}