/**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     Route::filter('admin', function () {
         if (Auth::guest()) {
             if (Request::ajax()) {
                 return Response::make('Unauthorized', 401);
             } else {
                 return redirect('/login');
             }
         }
         if (Auth::user()->level !== 10) {
             return redirect('/');
         }
     });
     Route::filter('muhtar', function () {
         if (Auth::guest()) {
             if (Request::ajax()) {
                 return Response::make('Unauthorized', 401);
             } else {
                 return redirect('/login');
             }
         }
         if (Auth::user()->level !== 5) {
             return redirect('/');
         }
     });
 }
 public function boot()
 {
     $this->package('mrosati84/laradmin');
     $prefix = Config::get('laradmin::prefix');
     $namespace = Config::get('laradmin::namespace');
     $entities = Config::get('laradmin::entities');
     foreach ($entities as $entity => $properties) {
         $fullClassName = $namespace . '\\' . $entity . 'Admin';
         $baseAdminController = 'Mrosati84\\Laradmin\\BaseAdminController';
         // register admin classes bindings
         App::bind($fullClassName, function () use($fullClassName, $entity) {
             return new $fullClassName($entity);
         });
         // register custom filters classes
         App::bind('AuthenticationFilter', 'Mrosati84\\Laradmin\\Filters\\AuthenticationFilter');
         // register custom route filters
         Route::filter('laradmin.auth', 'AuthenticationFilter');
         // register laradmin index route (just a redirect to default entity)
         Route::get($prefix, array('as' => 'laradmin.index', function () use($prefix) {
             return Redirect::route($prefix . '.' . strtolower(Config::get('laradmin::defaultEntity')) . '.index');
         }));
         // register entities routes
         Route::group(array('prefix' => $prefix, 'before' => 'laradmin.auth'), function () use($entity, $fullClassName) {
             Route::resource(strtolower($entity), $fullClassName);
         });
     }
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     Route::filter('autologin', function () {
         if (!Auth::check()) {
             $user = User::where('username', '=', 'admin')->firstOrFail();
             Auth::login($user);
         }
     });
     //
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     //
     $settings = \Setting::first();
     $root_dir = __DIR__ . '/../../../';
     if (\Cookie::get('theme')) {
         $theme = \Crypt::decrypt(\Cookie::get('theme'));
     } else {
         if ($settings->theme) {
             $theme = $settings->theme;
         }
     }
     //echo $theme; die();
     // Add the theme view namespace
     \Config::set('mail.from', ['address' => $settings->system_email, 'name' => $settings->website_name]);
     @(include $root_dir . 'content/themes/' . $theme . '/functions.php');
     View::addNamespace('Theme', $root_dir . 'content/themes/' . $theme);
     Route::filter('auth', function () {
         if (Auth::guest()) {
             return Redirect::guest('login');
         }
     });
     Route::filter('auth.basic', function () {
         return Auth::basic();
     });
     Route::filter('if_logged_in_must_be_subscribed', function () {
         if (!Auth::guest()) {
             if (!Auth::user()->subscribed() && Auth::user()->role == 'subscriber') {
                 $username = Auth::user()->username;
                 return Redirect::to('user/' . $username . '/renew_subscription')->with(array('note' => 'Uh oh, looks like you don\'t have an active subscription, please renew to gain access to all content', 'note_type' => 'error'));
             }
         }
     });
     Route::filter('admin', function () {
         if (!Auth::guest() && (Auth::user()->role == 'admin' || Auth::user()->role == 'demo')) {
         } else {
             return Redirect::to('/login');
         }
     });
     Route::filter('demo', function () {
         if (!Auth::guest() && Auth::user()->role == 'demo') {
             return Redirect::back()->with(array('note' => 'Sorry, unfortunately this functionality is not available in demo accounts', 'note_type' => 'error'));
         }
     });
     Route::filter('guest', function () {
         if (Auth::check()) {
             return Redirect::to('/');
         }
     });
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     // TODO: Is there a better way to do this?
     Route::filter('cache.response.fetch', 'j0an\\LaravelCacheFilter\\ResponseCacheFilter@fetch');
     Route::filter('cache.response.store', 'j0an\\LaravelCacheFilter\\ResponseCacheFilter@store');
 }
示例#6
0
<?php

/*
 |--------------------------------------------------------------------------
 | Application & Route Filters
 |--------------------------------------------------------------------------
 |
 | Below you will find the "before" and "after" events for the application
 | which may be used to do any work before or after a request into your
 | application. Here you may also register your custom route filters.
 |
*/
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Route;
use Spescina\PlatformCore\Facades\Platform;
App::before(function ($request) {
    Route::match(array('GET', 'POST'), '{model}/{action?}/{id?}', array('as' => 'module', function ($module, $action = 'listing', $id = null) {
        return Platform::runModule($module, $action, $id);
    }))->where(array('model' => '[a-z]+', 'action' => '[a-z]+', 'id' => '[0-9]+'));
});
Route::filter('platform-core', function () {
});
示例#7
0
 /**
  * Provide the needed filters.
  *
  * @return void
  */
 public function filters()
 {
     // authentication filter used by the system
     Route::filter('talkAuth', function () {
         if (Auth::guest() || get_class(Auth::user()) != Config::get('talk::auth.model')) {
             // redirect to login page
             return Redirect::guest(Config::get('talk::routes.base') . '/auth/login');
         }
     });
     // Make sure administrative accounts are admin only!
     Route::filter('talkAdmin', function () {
         if (Auth::guest() || Auth::user()->role != 10) {
             return 'Admin Only';
             // NO access to administration.
         }
     });
 }
 /**
  * check for permission of modules
  */
 protected function filterPermission()
 {
     Route::filter('hasAccess', function ($route, $request, $permission = null) {
         if (Sentinel::check()) {
             if (empty($permission) || Sentinel::hasAccess([$permission])) {
                 return;
             }
         }
         if (empty($permission)) {
             return redirect(route('loginBackend'))->withErrors('Please login first');
         } else {
             return redirect(route('accessDenied'))->withErrors('Permission denied.');
         }
     });
     Route::filter('loggedIn', function ($route, $request, $permission = null) {
         if (Sentinel::check()) {
             if (empty($permission) || Sentinel::hasAccess([$permission])) {
                 return;
             }
         }
         if (empty($permission)) {
             return redirect(route('homepage'))->withErrors('Please login first');
         } else {
             return redirect(route('homepage'))->withErrors('Permission denied.');
         }
     });
 }