本文整理匯總了PHP中Illuminate\Support\Facades\Request::is方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::is方法的具體用法?PHP Request::is怎麽用?PHP Request::is使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\Request
的用法示例。
在下文中一共展示了Request::is方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!Request::is('login/*')) {
return $next($request)->header('Access-Control-Allow-Origin', '*')->header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE')->header('Access-Control-Allow-Headers', 'Content-Type, Accept, Authorization, X-Requested-With, X-Auth-Token');
}
return $next($request);
}
示例2: whitelisted
static function whitelisted()
{
// Detect API Request
//
if (Input::get('api_key') && Input::get('user_uid')) {
if (Config::get('app.api_key') == Input::get('api_key')) {
if (!User::getIndex(Input::get('user_uid'))) {
return false;
}
Session::set('user_uid', Input::get('user_uid'));
return true;
}
return false;
}
// Detect Whitelisted Route
//
foreach (Config::get('app.whitelist') as $pattern) {
if (is_array($pattern)) {
if (Request::is(key($pattern))) {
return in_array(self::method(), current($pattern));
}
} else {
if (Request::is($pattern)) {
return true;
}
}
}
return false;
}
示例3: handle
/**
* Handle the specified event.
*/
public function handle()
{
$isOnAdmin = Request::is('admin') || Request::is('admin/*');
if (!$isOnAdmin) {
Visitor::track();
}
}
示例4: 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;
}
示例5: e
/**
* 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}\"";
}
示例6: foreach
/**
* Set active to specified selector.
*
* @param array|string $paths
* @param string $class
*
* @return string
*/
function set_active($paths, $class = 'active')
{
foreach ((array) $paths as $path) {
if (Request::is($path)) {
return $class;
}
}
}
示例7: register
/**
* Register the application services.
*
* @return void
*/
public function register()
{
if (!Request::is('file/*')) {
$this->loadViewsFrom(__DIR__ . '/../../views', $this->packageName);
$this->app->register(\Phileserver\Core\Providers\EventServiceProvider::class);
$this->app->routeMiddleware(['token' => 'Phileserver\\Core\\Http\\Middleware\\CheckToken']);
$this->registerCommands();
}
}
示例8: check
public function check($routes = [], $class = 'active')
{
foreach ($routes as $route) {
if (Request::is($route)) {
return $class;
}
}
return '';
}
示例9: __construct
/**
* @param ImageUploader $uploader
*/
public function __construct(ImageUploader $uploader)
{
$this->uploader = $uploader;
if (Request::is('admin/pages')) {
$this->articles = App::make(PagesRepository::className());
} else {
$this->articles = App::make(ArticleRepository::className());
}
}
示例10: isActive
/**
* @param Item $item
*
* @return bool
*/
public function isActive(Item $item)
{
// Check if one of the children is active
foreach ($item->getItems() as $item) {
if ($this->isActive($item)) {
return true;
}
}
// Custom set active path
if ($path = $item->getActiveWhen()) {
return Request::is($path);
}
$path = ltrim(str_replace(url('/'), '', $item->getUrl()), '/');
return Request::is($path, $path . '/*');
}
示例11: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
\HTML::macro('activeClass', function ($path, $active = 'active') {
if (Request::is($path . "*")) {
return $active;
}
return '';
});
\Validator::resolver(function ($translator, $data, $rules, $messages) {
return new CustomValidator($translator, $data, $rules, $messages);
});
\Blade::extend(function ($value) {
return preg_replace('/\\@define(.+)/', '<?php ${1}; ?>', $value);
});
}
示例12: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
if (collect(Analytics::find(1))->contains(1)) {
view()->share('analytics', Analytics::find(1));
}
if (collect(Configuracao::find(1))->contains(1)) {
view()->share('confsite', Configuracao::find(1));
}
if (collect(Comentarios::where('id_status_comentario', 1)->get())->count()) {
view()->share('comments', collect(Comentarios::where('id_status_comentario', 1)->get())->count());
}
view()->share('sobre', Sobres::findOrFail(1));
if (Request::is('blog') or Request::is('blog/*')) {
view()->share('categorias', Categoria::where('id_tipo_categoria', 3)->get());
view()->share('ultimas', collect(Noticia::todas())->take(4));
}
if (Request::is('admin') or Request::is('admin/*')) {
view()->share('ajuda', Helps::all());
}
}
示例13: handle
/**
* @param $request
* @param \Closure $next
* @param array $permissions
*
* @see http://laravel.com/docs/5.1/middleware#middleware-parameters
*
* @return \Illuminate\Http\RedirectResponse|\Laravel\Lumen\Http\Redirector
*/
public function handle($request, Closure $next, $permissions = [])
{
if (!is_array($permissions)) {
$permissions = [$permissions];
}
// no permission required
if (empty($permissions)) {
return $next($request);
}
Clockwork::startEvent('acl.middleware', 'Acl middleware.');
foreach ($permissions as $permission) {
if (!Acl::isUserAllow(Auth::user(), $permission)) {
Clockwork::stopEvent('acl.middleware');
if (Request::is('api*')) {
return response('Not authorized', 403);
} else {
return view('auth.notAuthorized');
}
}
}
Clockwork::stopEvent('acl.middleware');
return $next($request);
}
示例14: isProfilerCall
protected function isProfilerCall()
{
return Request::is('api/profiler/profiles*');
}
示例15: setActive
public static function setActive($path, $active = 'active')
{
return Request::is($path) ? $active : '';
}