public function authorize($route, $request)
 {
     $allowed = CanI::can('manage', $route->parameter('todos'));
     if ($route->parameter('todos') && !$allowed) {
         return App::abort(401);
     }
 }
 public function authorizeInvite($route, $request)
 {
     $allowed = CanI::can('invite', 'User');
     if (!$allowed) {
         return App::abort(401);
     }
 }
    Route::bind('organizations', function ($value, $route) {
        return Organization::where('slug', $value)->firstOrFail();
    });
    Route::resource('todos', 'TodosController');
    // Will remove for manual routes maybe?
    Route::model('todos', 'Todo');
    Route::resource('users', 'UsersController');
    Route::model('users', 'User');
    Route::get('styles/organization-custom.css', function (Organization $org) {
        $response = Response::make(View::make('organizations.css', ['css' => $org->css]));
        $response->header('Content-Type', 'text/css');
        return $response;
    });
});
View::composer('shared._notifications', function ($view) {
    $view->with('flash', ['success' => Session::get('success'), 'error' => Session::get('error')]);
});
View::share('currentUser', Auth::check() ? Auth::user() : new Guest());
View::share('isLoggedIn', Auth::check());
View::share('canI', function ($action, $entity) {
    return CanI::can($action, $entity);
});
function tenantRoute($route, $params = [])
{
    $params = (array) $params;
    if (!starts_with($route, ['sign-', 'organizations.']) && !isset($params['organizations'])) {
        $org = Route::current()->parameter('organizations');
        $params = array_merge(['organizations' => $org->slug], $params);
    }
    return URL::route($route, $params);
}
 public function authorize()
 {
     if (CanI::cannot('manage', $this->currentOrg())) {
         return App::abort(401);
     }
 }