current() public static method

Get the currently dispatched route instance.
public static current ( ) : Illuminate\Routing\Route
return Illuminate\Routing\Route
 /**
  * Get the subdomain parameter value
  *
  * @return string|null subdomain parameter value
  */
 private function getSubDomainParameter()
 {
     if (\Route::current() && ($param = \Route::input(config('tenant.subdomain')))) {
         return $param;
     }
     return $this->extractSubdomainFromUrl();
 }
 protected function currentOrg()
 {
     if (!$this->currentOrg) {
         $this->currentOrg = Route::current()->parameter('organizations');
     }
     return $this->currentOrg;
 }
Example #3
0
 /**
  * Initializer.
  *
  * @access   public
  * @return \BaseController
  */
 public function __construct()
 {
     $this->beforeFilter('csrf', array('on' => 'post'));
     $action = explode('@', Route::current()->getAction()['controller'])[1];
     Log::info($action);
     View::share('action', $action);
 }
Example #4
0
 public function filter()
 {
     //if(Auth::guest()) return Redirect::guest('login');
     $user = \Auth::user();
     //Determinar ruta para determinar acción
     $ruta_actual = \Route::current()->getUri();
     $accion = \Accion::whereRuta($ruta_actual)->with('modulos')->get();
     //Consultar modulo(s) al que pertenece la acción
     $modulos_accion = $accion[0]->modulos;
     //Consultar roles que permiten el acceso al modulo
     foreach ($modulos_accion as $modulo) {
         $arr_roles_id_modulo[] = $modulo->roles[0]->id;
     }
     //Consultar roles del usuario
     $roles_usuario = $user->roles;
     foreach ($user->roles as $role) {
         $arr_roles_id_usuario[] = $role->id;
     }
     //Validar roles del usuario contra roles del módulo
     $arr_validacion = array_intersect($arr_roles_id_usuario, $arr_roles_id_modulo);
     if (count($arr_validacion) == 0) {
         /**
          * @todo Redireccionar a página de inicio del usuario
          */
         return \Redirect::to('/')->with('flash_message', 'No tiene los derechos para acceder a este módulo');
     }
 }
 /**
  * Get the subdomain parameter value
  *
  * @return string|null subdomain parameter value
  */
 private function getSubDomainParameter()
 {
     if (\Route::current()) {
         return \Route::input(config('tenant.subdomain'));
     }
     return null;
 }
Example #6
0
 /**
  * Creates the view object for the HTML client.
  *
  * @param \MW_Config_Interface $config Configuration object
  * @param array $templatePaths List of base path names with relative template paths as key/value pairs
  * @param string|null $locale Code of the current language or null for no translation
  * @return \MW_View_Interface View object
  */
 public function create(\MW_Config_Interface $config, array $templatePaths, $locale = null)
 {
     $params = $fixed = array();
     if ($locale !== null) {
         $params = \Route::current()->parameters() + \Input::all();
         $params['target'] = \Route::currentRouteName();
         $fixed = $this->getFixedParams();
         $i18n = app('\\Aimeos\\Shop\\Base\\I18n')->get(array($locale));
         $translation = $i18n[$locale];
     } else {
         $translation = new \MW_Translation_None('en');
     }
     $view = new \MW_View_Default();
     $helper = new \MW_View_Helper_Translate_Default($view, $translation);
     $view->addHelper('translate', $helper);
     $helper = new \MW_View_Helper_Url_Laravel5($view, app('url'), $fixed);
     $view->addHelper('url', $helper);
     $helper = new \MW_View_Helper_Partial_Default($view, $config, $templatePaths);
     $view->addHelper('partial', $helper);
     $helper = new \MW_View_Helper_Parameter_Default($view, $params);
     $view->addHelper('param', $helper);
     $helper = new \MW_View_Helper_Config_Default($view, $config);
     $view->addHelper('config', $helper);
     $sepDec = $config->get('client/html/common/format/seperatorDecimal', '.');
     $sep1000 = $config->get('client/html/common/format/seperator1000', ' ');
     $helper = new \MW_View_Helper_Number_Default($view, $sepDec, $sep1000);
     $view->addHelper('number', $helper);
     $helper = new \MW_View_Helper_FormParam_Default($view, array());
     $view->addHelper('formparam', $helper);
     $helper = new \MW_View_Helper_Encoder_Default($view);
     $view->addHelper('encoder', $helper);
     $helper = new \MW_View_Helper_Csrf_Default($view, '_token', csrf_token());
     $view->addHelper('csrf', $helper);
     return $view;
 }
Example #7
0
 /**
  * Creates the view object for the HTML client.
  *
  * @param \Aimeos\MW\Config\Iface $config Configuration object
  * @param array $templatePaths List of base path names with relative template paths as key/value pairs
  * @param string|null $locale Code of the current language or null for no translation
  * @return \Aimeos\MW\View\Iface View object
  */
 public function create(\Aimeos\MW\Config\Iface $config, array $templatePaths, $locale = null)
 {
     $params = $fixed = array();
     if ($locale !== null) {
         $params = \Route::current()->parameters() + \Input::all();
         $fixed = $this->getFixedParams();
         $i18n = app('\\Aimeos\\Shop\\Base\\I18n')->get(array($locale));
         $translation = $i18n[$locale];
     } else {
         $translation = new \Aimeos\MW\Translation\None('en');
     }
     $view = new \Aimeos\MW\View\Standard($templatePaths);
     $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $translation);
     $view->addHelper('translate', $helper);
     $helper = new \Aimeos\MW\View\Helper\Url\Laravel5($view, app('url'), $fixed);
     $view->addHelper('url', $helper);
     $helper = new \Aimeos\MW\View\Helper\Param\Standard($view, $params);
     $view->addHelper('param', $helper);
     $helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config);
     $view->addHelper('config', $helper);
     $sepDec = $config->get('client/html/common/format/seperatorDecimal', '.');
     $sep1000 = $config->get('client/html/common/format/seperator1000', ' ');
     $helper = new \Aimeos\MW\View\Helper\Number\Standard($view, $sepDec, $sep1000);
     $view->addHelper('number', $helper);
     $helper = new \Aimeos\MW\View\Helper\Request\Laravel5($view, \Request::instance());
     $view->addHelper('request', $helper);
     $helper = new \Aimeos\MW\View\Helper\Csrf\Standard($view, '_token', csrf_token());
     $view->addHelper('csrf', $helper);
     return $view;
 }
Example #8
0
 public function __construct($missing = false)
 {
     if ($missing) {
         return;
     }
     $this->params = \Route::current()->parameters();
 }
Example #9
0
 static function scripts($scripts)
 {
     $route = Route::current()->action;
     if ($route == "index" or $route == "archive" or $route == "search") {
         $scripts[] = Config::current()->chyrp_url . "/modules/cascade/javascript.php";
         return $scripts;
     }
 }
Example #10
0
 public static function evaluateTextInView($text, $dependencies = null)
 {
     if (!$dependencies) {
         $route = \Route::current();
         $dependencies = $route->parameters();
     }
     return self::evaluateText($text, $dependencies);
 }
Example #11
0
 static function __uninstall($confirm)
 {
     if ($confirm) {
         Category::uninstallCategorize();
     }
     Group::remove_permission('manage_categorize');
     Route::current()->remove("category/(name)/");
 }
Example #12
0
/**
 * Return all route parameters
 * @return array
 */
function zbase_route_inputs()
{
    $routing = \Route::current();
    if ($routing instanceof \Illuminate\Routing\Route) {
        return $routing->parameters();
    }
    return [];
}
Example #13
0
 function change_locale($locale)
 {
     $route = Route::current();
     $oldParams = $route->parameters();
     unset($oldParams['lang']);
     $params = array_merge([$locale], $oldParams);
     return route($route->getName(), $params);
 }
Example #14
0
 protected function view($file = false, $data = false)
 {
     $data = (array) ($data ? $data : $this->data);
     if (!$file) {
         $file = \Route::current()->getAction()["as"];
     }
     return view($file, $data);
 }
 protected function getAncestorNodeForCurrentRoute()
 {
     $currentRoute = \Route::current()->getUri();
     $currentRoute = preg_replace('/^(get|post|put|delete) /i', '', $currentRoute);
     if ($navItem = NavItem::where('descendants_routes', 'LIKE', '%' . $currentRoute . '%')->first()) {
         return $navItem;
     }
     return null;
 }
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);
}
Example #17
0
File: Map.php Project: larakit/lk
 function getCurrent()
 {
     $access_name = \Route::currentRouteName();
     $params = \Route::current()->parameters();
     if ($params) {
         $access_name .= '.' . str_replace(['&', '='], ['.', '-'], http_build_query($params));
     }
     return Arr::get($this->map, $access_name);
 }
Example #18
0
function thisAction($action, $params = [])
{
    $route = Route::current()->getAction()['controller'];
    $controller = "\\" . explode('@', $route)[0];
    if (!$action) {
        $action = 'index';
    }
    return action($controller . '@' . $action, $params);
}
Example #19
0
/**
 * Check if a category should be active acording to the route
 *
 * @param $category
 * @param $pos
 * @return bool
 */
function activeCategory($category, $pos = null)
{
    $route = Route::current();
    $params = $route->parameters();
    $param = isset($params['category']) ? $params['category'] : null;
    if ($route->getName() == 'home') {
        return $param == $category->slug || $pos == 0 && $param == null;
    }
    return false;
}
 public function __construct()
 {
     $this->_user = Auth::user();
     $this->_parameters = Route::current()->parameters();
     if (!User::hasHotelPermission($this->_user, $this->_parameters['hotels'])) {
         if (!Entrust::hasRole('Admin')) {
             App::abort(403);
         }
     }
 }
Example #21
0
 public function split($text, $post)
 {
     if (!strpos($text, "(((page)))")) {
         return $text;
     }
     $text = preg_replace("/(<p>)?(\\(\\(\\(page\\)\\)\\))(<\\/p>|<br \\/>)?/", "\\2", $text);
     $split_pages = explode("(((page)))", $text);
     $post->paginated = new Paginator($split_pages, 1, Route::current()->action == "view" ? "page" : "post_page");
     return $post->paginated->result[0];
 }
Example #22
0
function getRouteMethod()
{
    $list_routes = ['create', 'edit', 'store', 'index', 'update', 'destroy', 'show'];
    $current = Route::current()->getUri();
    $method = explode('/', $current);
    $return = null;
    if (in_array(end($method), $list_routes)) {
        $return = end($method);
    }
    return $return;
}
Example #23
0
 public function source()
 {
     list($controller, $method) = explode('@', \Route::current()->getAction()['controller']);
     $source = Documenter::showMethod($controller, [$method]);
     foreach ($this->views as $v) {
         if (!str_is('*/layout/*', $v)) {
             $source .= Documenter::showCode($v);
         }
     }
     return $source;
 }
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     switch ($this->method()) {
         case 'POST':
             return ['username' => 'required|alpha_dash', 'email' => 'required|email', 'password' => 'required|between:8,20|confirmed'];
         case 'PATCH':
             // Grab the user id from the URL
             $user_id = \Route::current()->getParameter('users');
             return ['username' => 'required|alpha_dash', 'email' => 'unique:users,email,' . $user_id . '|email|required', 'password' => 'required|between:8,20|confirmed'];
     }
 }
 /**
  * constructor
  *
  * @param PostService $post
  * @param RssService  $rss
  */
 public function __construct(PostService $post, RssService $rss)
 {
     $this->middleware('auth');
     if (auth()->check()) {
         $postId = \Route::current()->getParameter('post');
         if ($postId && auth()->user()->id !== $post->find($postId)->user->id) {
             $this->middleware('permission:manage-all-content');
         }
     }
     $this->post = $post;
     $this->rss = $rss;
 }
Example #26
0
 public function __construct($query = null)
 {
     if (is_null($query) && !is_null($this->modelClass)) {
         $model = $this->modelClass;
         $this->query = $model::query();
     } else {
         $this->query = $query;
     }
     $this->params = array_merge(\Route::current()->parameters(), \Request::input());
     if (method_exists($this, 'prepare')) {
         $this->prepare();
     }
 }
 public function loadStore()
 {
     $current_params = \Route::current()->parameters();
     $storeID = $current_params['store_id'];
     if (!$storeID) {
         \App::abort(404);
     }
     $storeDO = $this->storeRepository->findOneById($storeID);
     if (!$storeDO) {
         \App::abort(404);
     }
     return $storeDO;
 }
/**
 * Array View Helper
 * 
 * @param  array  $items
 * @return array
 */
function helper_links($items = [])
{
    $hrefSelf = Request::fullUrl();
    $links = ['self' => ['href' => $hrefSelf, 'type' => 'application/json; version=1.0']];
    if (count($items)) {
        $last = $items[count($items) - 1];
        $currentRoute = Route::current();
        $queries = Input::all();
        $queries = array_merge($queries, ['cursor' => $last->id]);
        $hrefNext = url($currentRoute->getPath()) . '?' . http_build_query($queries);
        $links['next'] = ['href' => $hrefNext, 'type' => 'application/json; version=1.0'];
    }
    return $links;
}
Example #29
0
 public function add_option($options, $post = null)
 {
     if (isset($post) and $post->feather != "file") {
         return;
     } elseif (Route::current()->action == "write_post") {
         if (!isset($_GET['feather']) and Config::current()->enabled_feathers[0] != "file" or isset($_GET['feather']) and $_GET['feather'] != "file") {
             return;
         }
     }
     $options[] = array("attr" => "option[source]", "label" => __("Source", "file"), "type" => "text", "value" => oneof(@$post->source, ""));
     $options[] = array("attr" => "from_url", "label" => __("From URL?", "file"), "type" => "text");
     $options[] = array("attr" => "mime_type", "label" => __("Mime type", "file"), "type" => "text");
     return $options;
 }
 public function loadAttributeSet()
 {
     $current_params = \Route::current()->parameters();
     $attributeSetID = $current_params['attribute_set_id'];
     if (!$attributeSetID) {
         \App::abort(404);
     }
     $attributeSetDO = $this->attributeSetRepository->findOneById($attributeSetID);
     if (!$attributeSetDO) {
         \App::abort(404);
     }
     $this->attributeSet = $attributeSetDO;
     \View::share('attributeSet', $attributeSetDO);
 }