当前位置: 首页>>代码示例>>PHP>>正文


PHP Route::filter方法代码示例

本文整理汇总了PHP中Route::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::filter方法的具体用法?PHP Route::filter怎么用?PHP Route::filter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Route的用法示例。


在下文中一共展示了Route::filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app['mobiledetect'] = $this->app->share(function ($app) {
         return new \Mobile_Detect();
     });
     $this->app['facebook'] = $this->app->share(function ($app) {
         return new Facebook();
     });
     \Route::filter('facebook-scope', 'L4FacebookToolsFilter');
 }
开发者ID:mrynk,项目名称:l4-facebook-tools,代码行数:15,代码来源:L4FacebookToolsServiceProvider.php

示例2: routes

 public function routes()
 {
     \Route::filter('NewsLetter', function () {
         $permission = module("UserManagement");
         if (!$permission->hasPermission('NewsLetter')) {
             return \Redirect::route('dashboard');
         }
     });
     Route::pattern('id', '[0-9]+');
     $this->NewsLetter();
 }
开发者ID:PhonemeCms,项目名称:cms,代码行数:11,代码来源:NewsLetterRoutes.php

示例3: boot

 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     // Add package
     $this->package('leitom/role');
     // Register the role manager filter
     // This filter is used to trigger the protection of routes.
     // It will also contain the auth before filter so that it does not have to
     // be implemented at the same time.
     \Route::filter($this->app['config']->get('role::role.control.identifier'), 'Leitom\\Role\\Filters\\Role');
     // Bind the implementation for use in controllers
     $this->app->bind('Leitom\\Role\\Contracts\\RoleRepositoryInterface', 'Leitom\\Role\\Repositories\\EloquentRoleRepository');
     $this->app->bind('Leitom\\Role\\Contracts\\RouteRepositoryInterface', 'Leitom\\Role\\Repositories\\EloquentRouteRepository');
     $this->app->bind('Leitom\\Role\\Contracts\\RouteScannerInterface', 'Leitom\\Role\\RouteScanner');
 }
开发者ID:leitom,项目名称:role,代码行数:19,代码来源:RoleServiceProvider.php

示例4: testPermissionsCanBeSetForRoutes

 public function testPermissionsCanBeSetForRoutes()
 {
     $user = $this->createUserWithRoles();
     \ACL::setUser($user);
     $controller = Mockery::mock('\\ApiController');
     $controller->shouldReceive('tests')->once()->andReturn(\Response::json(['success' => 'great']));
     $controller->shouldReceive('getActionPermissions')->once()->andReturn(['tests' => 'job.apply']);
     \Route::enableFilters();
     \Route::filter('test.permissions.filter', function ($route) {
         require 'app/acl.php';
         $permissions = $route->getAction()['uses'][0]->getActionPermissions();
         $perm = $permissions[$route->getAction()['uses'][1]];
         $this->assertTrue(ACL::permits('job.apply', $route->parameters()));
     });
     \Route::get('/test/perms/{id}', [$controller, 'tests'])->after('test.permissions.filter');
     $this->call('GET', '/test/perms/3');
     $this->assertResponseOk();
 }
开发者ID:nilove,项目名称:motibubackend,代码行数:18,代码来源:PermissionsTest.php

示例5: function

| cross-site request forgery attacks. If this special token in a user
| session does not match the one given in this request, we'll bail.
|
*/
Route::filter('csrf', function () {
    if (Session::token() != Input::get('_token')) {
        throw new Illuminate\Session\TokenMismatchException();
    }
});
Route::filter('checkInstalled', function ($route, $request) {
    $installed = false;
    try {
        $installed = Setting::get('faxbox.installed', true);
    } catch (PDOException $e) {
        if ($request->getRequestUri() == '/install') {
            return;
        } else {
            return Redirect::to('install');
        }
    }
    if (!$installed && $request->getRequestUri() == '/install') {
        return;
    }
    if (!$installed) {
        return Redirect::to('install');
    }
    // If we've gotten here, then the app is installed. send them to the dashboard
    if ($request->getRequestUri() == '/install' && $installed) {
        return Redirect::route('home');
    }
});
开发者ID:jeanfrancis,项目名称:faxbox,代码行数:31,代码来源:filters.php

示例6: foreach

            return Response::make('Unauthorized', 401);
        }
        return Redirect::guest('/');
    }
    $return = 0;
    foreach (Auth::user()->groups as $group) {
        foreach ($group->resources as $resource) {
            if ($resource->pattern == "/" . Route::getCurrentRoute()->getPath()) {
                $return = 1;
            }
        }
    }
    if ($return == 0) {
        return Redirect::to('/profile');
    } else {
        return;
    }
});
Route::filter("guest", function () {
    if (Auth::check()) {
        if (Route::getCurrentRoute()->getPath() == "login") {
            return Redirect::route("user/profile");
        }
        //
    }
});
Route::filter("csrf", function () {
    if (Session::token() != Input::get("_token")) {
        throw new Illuminate\Session\TokenMismatchException();
    }
});
开发者ID:alejandromorg,项目名称:Inventario,代码行数:31,代码来源:filters.php

示例7: array

Route::get('/', array('as' => 'inicio', 'uses' => 'HomeController@getInicio'));
Route::get('/nosotros', array('as' => 'nosotros', 'uses' => 'HomeController@getNosotros'));
Route::get('/servicios', array('as' => 'servicios', 'uses' => 'HomeController@getServicios'));
Route::get('/galeria', array('as' => 'galeria', 'uses' => 'HomeController@getGaleria'));
Route::get('/transparencia', array('as' => 'transparencia', 'uses' => 'HomeController@getTransparencia'));
Route::get('/contacto', array('as' => 'contacto', 'uses' => 'HomeController@getContacto'));
Route::post('/contacto', array('as' => 'contacto', 'uses' => 'HomeController@postContacto'));
// rutas agrupadas para admin
// filtro para auth
Route::group(array('before' => 'auth.admin'), function () {
    Route::get('/admin', array('as' => 'admin.index', 'uses' => 'AdminController@getIndex'));
    Route::get('/admin/salir', array('as' => 'logout', 'uses' => 'AdminController@getLogOut'));
    Route::get('/admin/perfil-usuario', array('as' => 'perfil', 'uses' => 'AdminController@getPerfil'));
    Route::get('/admin/usuarios', array('as' => 'usuarios', 'uses' => 'AdminController@getUsuarios'));
    Route::get('/admin/usuarios/nuevo', array('as' => 'usuariosNuevo', 'uses' => 'AdminController@getUsuariosNuevo'));
    Route::post('/admin/usuarios/nuevo', array('uses' => 'AdminController@postUsuariosNuevo'));
    Route::get('/admin/usuarios/editar/{id}', array('uses' => 'AdminController@getUsuariosEditar'));
    Route::post('/admin/usuarios/editar', array('uses' => 'AdminController@postUsuariosEditar'));
    Route::get('/admin/usuarios/bloquear/{id}', array('uses' => 'AdminController@getUsuariosBloquear'));
    Route::get('/admin/usuarios/activar/{id}', array('uses' => 'AdminController@getUsuariosActivar'));
    Route::get('/admin/listar-pedidos', array('as' => 'pedidos', 'uses' => 'PedidosController@getPedidos'));
    Route::get('/admin/paginas/inicio', array('uses' => 'AdminController@getPaginasInicio'));
    Route::get('/admin/importar-datos', array('as' => 'stock', 'uses' => 'ProductosController@getStock'));
    Route::post('/admin/stock', array('uses' => 'ProductosController@postStock'));
});
// filtro auth
Route::filter('auth.admin', function () {
    if (!Sentry::check()) {
        return Redirect::route('login');
    }
});
开发者ID:appsmambo,项目名称:WebApupal,代码行数:31,代码来源:routes.php

示例8: function

        if (!$request->ajax()) {
            return Redirect::guest('login');
        } else {
            return Response::make('Unauthorized Access', 403);
        }
    }
});
Route::filter('auth.basic', function () {
    return Auth::basic();
});
Route::filter('guest', function ($route, $request) {
    if (Auth::guest()) {
        //
    } else {
        if (!$request->ajax()) {
            return Redirect::guest('admin/dashboard');
        } else {
            return Response::make('Unauthorized Access', 403);
        }
    }
});
// Role-based Authorization Filter.
Route::filter('roles', function ($route, $request, $response, $roles = null) {
    if (!is_null($roles) && Auth::check()) {
        $user = Auth::user();
        if (!$user->hasRole($roles)) {
            $status = __('You are not authorized to access this resource.');
            return Redirect::to('admin/dashboard')->withStatus($status, 'warning');
        }
    }
});
开发者ID:LuckyCyborg,项目名称:simple-mvc-framework,代码行数:31,代码来源:Filters.php

示例9: function

|		Route::filter('filter', function()
|		{
|			return 'Filtered!';
|		});
|
| Next, attach the filter to a route:
|
|		Router::register('GET /', array('before' => 'filter', function()
|		{
|			return 'Hello World!';
|		}));
|
*/
Route::filter('before', function () {
    // Do stuff before every request to your application...
});
Route::filter('after', function ($response) {
    // Do stuff after every request to your application...
});
Route::filter('csrf', function () {
    if (Request::forged()) {
        return Response::error('500');
    }
});
Route::filter('auth', function () {
    if (Auth::guest()) {
        return Redirect::to('login');
    }
});
// Route for User_Controller
Route::controller('user');
开发者ID:nfourtythree,项目名称:eventumapp,代码行数:31,代码来源:routes.php

示例10: function

<?php

Route::filter('auth_check', function () {
    // check method move to config file
    if (Auth::guest()) {
        $login_url = URL::to(Config::get('rpc::auth.login_path'), 'login');
        return Redirect::to($login_url);
    }
});
开发者ID:bluebanner,项目名称:rpc,代码行数:9,代码来源:filters.php

示例11: function

<?php

Route::filter('MultilinguaSwapFilter', function () {
    $lista_lingue = L::get_lista();
    $lingua = array_values(explode('/', Request::path()))[0];
    if (in_array($lingua, array_keys($lista_lingue))) {
        // if not blocked
        if (!Session::get('noswap')) {
            // updates the language
            L::set($lingua);
            L::updateLocale();
        }
    } else {
        // not found
        app::abort('404');
    }
});
开发者ID:palmabit,项目名称:multilanguage,代码行数:17,代码来源:filters.php

示例12: function

<?php

Route::filter('admin.auth', function () {
    if (AdminAuth::guest()) {
        if (Request::ajax()) {
            return Response::make('Unauthorized', 401);
        } else {
            return Redirect::guest(Admin::instance()->router->routeToAuth('login'));
        }
    }
});
开发者ID:GlobalsDD,项目名称:admin,代码行数:11,代码来源:filters.php

示例13: function

<?php

Route::filter('csrf-ajax', function () {
    if (Session::token() != Request::header('x-csrf-token')) {
        throw new Illuminate\Session\TokenMismatchException();
    }
});
Route::get('/', 'IndexController@index');
Route::post('show', ['before' => 'csrf-ajax', 'as' => 'show', 'uses' => 'IndexController@show']);
Route::post('create', ['before' => 'csrf-ajax', 'as' => 'create', 'uses' => 'IndexController@create']);
Route::get('article/{id}/{title}', ['as' => 'read', 'uses' => 'IndexController@read']);
开发者ID:ArtiResh,项目名称:mytest,代码行数:11,代码来源:routes.php

示例14: function

    if (Auth::check()) {
        return Redirect::to('/user/profile');
    }
});
/*
|--------------------------------------------------------------------------
| CSRF Protection Filter
|--------------------------------------------------------------------------
|
| The CSRF filter is responsible for protecting your application against
| cross-site request forgery attacks. If this special token in a user
| session does not match the one given in this request, we'll bail.
|
*/
Route::filter('csrf', function () {
    if (Session::token() !== Input::get('_token')) {
        throw new Illuminate\Session\TokenMismatchException();
    }
});
Route::filter('admin', function () {
    if (Auth::guest()) {
        if (Request::ajax()) {
            return Response::make('Unauthorized', 401);
        }
        return Redirect::guest('user/login');
    } else {
        if (Auth::check() && Auth::user()->role != 1) {
            return Redirect::to('/user/profile');
        }
    }
});
开发者ID:apetrailmukesh,项目名称:bootstrap,代码行数:31,代码来源:filters.php

示例15: function

<?php

Route::filter('ulogin-guest', function () {
    if (Auth::check()) {
        $uri = Config::get('ulogin-laravel::config.redirect_after_login');
        return Redirect::to($uri);
    }
});
开发者ID:franzose,项目名称:ulogin-laravel,代码行数:8,代码来源:filters.php


注:本文中的Route::filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。