getCurrentRoute() public static method

Get the currently dispatched route instance.
public static getCurrentRoute ( ) : Illuminate\Routing\Route
return Illuminate\Routing\Route
Exemplo n.º 1
0
/**
 *
 */
function admin_header_active($name)
{
    if (Route::getCurrentRoute()->getName() == $name) {
        return 'active';
    }
    return '';
}
Exemplo n.º 2
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$this->modelAdmin->find(\Route::getCurrentRoute()->getParameter('one'))) {
         return Response::view('flare::admin.404', [], 404);
     }
     return $next($request);
 }
 protected function setUp()
 {
     $this->current_route = Route::getCurrentRoute()->getName();
     $this->logged_user = Sentry::getUser();
     View::share('logged_user', $this->logged_user);
     View::share('current_route', $this->current_route);
 }
Exemplo n.º 4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $route = Route::getCurrentRoute()->getPath();
     if ('/admin/disciplinas' == $route) {
         $conteudoDisciplinas = new Disciplinas();
         /*$id = Input::get('id');
           if($id>0){
               $conteudoDisciplinas = Disciplinas::find($id);
           }*/
         $conteudoDisciplinas->nome_dis = Request::get('nomeDisciplina');
         $conteudoDisciplinas->codigo_dis = Request::get('codigoDisciplina');
         $conteudoDisciplinas->periodo_dis = Request::get('periodoDisciplina');
         $conteudoDisciplinas->save();
         $value = array('success' => true);
         //        return json_encode($value);
         return Redirect::to('/admin/disciplinas');
     }
     if ('/admin/professores' == $route) {
         return 'oi';
     }
     /*switch($route){
                 case '/admin/disciplinas/add':
                     $queryBuilder = 'Disciplinas';
                     break;
                 default:
                     break;
             }
     
             $updater    = new $queryBuilder();*/
 }
Exemplo n.º 5
0
 function routeActive($route, $children = [], $simple = false)
 {
     $found = false;
     $currentRoute = Route::getCurrentRoute()->getName();
     if ($children instanceof Illuminate\Support\Collection) {
         $children = $children->toArray();
     }
     if ($route == $currentRoute || in_array($currentRoute, $children)) {
         $found = true;
     } elseif (substr($route, -1) == '*' && checkPartialRoute($route, $currentRoute) == true) {
         $found = true;
     } else {
         foreach ($children as $child) {
             if (checkPartialRoute($child, $currentRoute) == true) {
                 $found = true;
                 break;
             }
         }
     }
     if ($found == true) {
         if ($simple) {
             return 'active';
         } else {
             return "class='active'";
         }
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     /*
      * return paginated results to do infinite scroll, maybe?
      */
     $works = Work::with(['photos' => function ($photos) {
         /*
          * Return only the selected columns
          *
          * Includes the foreign key to the field list,
          * or else Laravel won't be able to link the
          * models together
          */
         $photos->addSelect(['id', 'filename', 'work_id']);
     }, 'agency' => function ($agencies) {
         /*
          * Return only the selected columns
          *
          * No need to include foreing key here since
          * Work "belongsTo" an agency
          */
         $agencies->addSelect(['id', 'name']);
         // @TODO ✅ Lower this pagination?
     }])->latest()->published()->orderBy('featured', 'desc')->paginate(50);
     /*
      * If we are in the admin panel, render a view
      * otherwise return as json
      */
     $routeName = \Route::getCurrentRoute()->getName();
     return $routeName == 'dash.works' ? view('dashboard.works.index', compact('works')) : $works;
 }
Exemplo n.º 7
0
 public function __construct()
 {
     if (\App::runningInConsole()) {
         $this->request = [];
     } else {
         $this->request = ['url' => request()->url(), 'method' => request()->method(), 'input' => request()->input(), 'action' => \Route::getCurrentRoute() !== null ? \Route::getCurrentRoute()->getAction() : null, 'headers' => request()->header()];
     }
 }
Exemplo n.º 8
0
function getActive($id)
{
    $currentRoute = Route::getCurrentRoute()->getParameter('category_id');
    if ($id == $currentRoute) {
        return 'active';
    }
    return '';
}
Exemplo n.º 9
0
 /**
  * Return the header title for each page
  *
  * @return string
  */
 function _headerTitle()
 {
     $route = Route::currentRouteName();
     $title = '<h1 class="page-heading">';
     $title .= trans(Route::getCurrentRoute()->getName());
     $title .= '</h1>';
     return $title;
 }
Exemplo n.º 10
0
function getActiveLink($name)
{
    $current = Route::getCurrentRoute()->getPath();
    if ($name == $current) {
        echo 'active';
    }
    echo '';
}
Exemplo n.º 11
0
 public function getIndex()
 {
     $id = Sentry::getUser()->id;
     $hoy = date('Y-m-d');
     $ruta = \Route::getCurrentRoute();
     $data['url'] = url($ruta->getPath());
     $data['bitacoras'] = Bitacora::where('usuario_id', '=', $id)->where('ind_atendida', '=', 'false')->where('ind_alarma', '=', 'true')->where('fecha', '<=', $hoy)->get();
     return View::make('solicitudes.alertas', $data);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     /*
      * Return paginated results, I might not need this route...
      */
     $photos = Photo::latest()->paginate(25);
     $routeName = \Route::getCurrentRoute()->getName();
     return $routeName == 'dash.photos' ? view('dashboard.photos.index', compact('photos')) : $photos;
 }
Exemplo n.º 13
0
 public function after()
 {
     if (strlen($this->response) > 0) {
         echo $this->response;
     } else {
         $currentRoute = Route::getCurrentRoute();
         echo $this->view->render($currentRoute[1][0] . '/' . $currentRoute[1][1]);
     }
 }
Exemplo n.º 14
0
 public static function link_to_sorting_action($col, $title = null)
 {
     if (is_null($title)) {
         $title = str_replace('_', ' ', $col);
         $title = ucfirst($title);
     }
     $indicator = Input::get('s') == $col ? Input::get('o') === 'asc' ? '&uarr;' : '&darr;' : null;
     $parameters = array_merge(Route::getCurrentRoute()->parameters(), array('s' => $col, 'o' => Input::get('o') === 'asc' ? 'desc' : 'asc'));
     return link_to_route(Route::currentRouteName(), "{$title} {$indicator}", $parameters);
 }
Exemplo n.º 15
0
 /**
  * 
  * @return boolean Пункт меню выбран
  */
 public function isSelected()
 {
     // Разбираем запрос, ищем текущий элемент меню.
     $pageAction = Route::getCurrentRoute()->action;
     foreach ($this->actions as $action) {
         if ($pageAction == $action) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 16
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     $route = \Route::getCurrentRoute();
     $actionName = $route->getActionName();
     if (!empty($actionName) && $actionName !== 'Closure') {
         $segments = explode('@', $actionName);
         $controller = \App::make($segments[0]);
         $controller->authorize($route->getName());
     }
     return $next($request);
 }
Exemplo n.º 17
0
 /**
  * @return mixed get the data to be serialized
  */
 public function getData()
 {
     $data = array('currentRoute' => \Route::getCurrentRoute());
     $base_path = Request::root();
     $routes = \Route::getRoutes()->all();
     $results = array();
     foreach ($routes as $name => $route) {
         $results[] = $this->getRouteInformation($name, $route, $data['currentRoute'], $base_path);
     }
     $data['routes'] = $results;
     return array('router' => $data);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     /*
      * Return all agencies since there aren't that many
      */
     $agencies = Agency::all();
     /*
      * If we are in the admin panel, render a view
      * otherwise return as json
      */
     $routeName = \Route::getCurrentRoute()->getName();
     return $routeName == 'dash.agencies' ? view('dashboard.agencies.index', compact('agencies')) : $agencies;
 }
Exemplo n.º 19
0
 /**
  * Get the evaluated view contents for the given view.
  *
  * @param  string  $view
  * @param  array   $data
  * @param  array   $mergeData
  * @return \Illuminate\View\View
  */
 function viewc($view = null, $data = array(), $mergeData = array())
 {
     $router = Route::getCurrentRoute()->getActionName();
     $module = substr($router, strripos($router, 'Controllers\\') + 12, strrpos($router, '\\') - (strripos($router, 'Controllers\\') + 12));
     $controller = substr($router, strripos($router, '\\') + 1, strpos($router, 'Controller@') - (strripos($router, '\\') + 1));
     $action = substr($router, strpos($router, '@') + 1);
     $route = ['module' => $module, 'controller' => $controller, 'action' => $action];
     $data = array_merge($data, $route);
     $factory = app('Illuminate\\Contracts\\View\\Factory');
     if (func_num_args() === 0) {
         return $factory;
     }
     return $factory->make($view, $data, $mergeData);
 }
Exemplo n.º 20
0
 public function rules()
 {
     $method = $this->method();
     $route = \Route::getCurrentRoute()->getPath();
     switch ($method) {
         case 'GET':
         case 'DELETE':
             return [];
         case 'POST':
             //     	if($route == 'api/auth/login')
             //     	{
             //       return [
             //           'email' => 'required',
             //           'password' => 'required',
             //       ];
             //     	}
             //     	else if($route == 'api/auth/forgot')
             //     	{
             //       return [
             //           'email' => 'required',
             //       ];
             //     	}
             //     	else if($route == 'api/system_users/image')
             //     	{
             // return [
             //           'user_image_upload' => 'required|image',
             //       ];
             //     	}
             //     	else if($route == 'api/auth/password')
             //     	{
             // return [
             //           'old_password' => 'required',
             //           'new_password' => 'required',
             //           'confirm_password' => 'required',
             //       ];
             //     	}
             // else
             // {
             return ['language' => 'required|unique:language', 'code' => 'required'];
             //}
         case 'PUT':
             return ['language' => 'unique:language,language,' . \Request::input('id'), 'code' => 'required'];
         case 'PATCH':
         default:
             break;
     }
 }
Exemplo n.º 21
0
 /**
  * Returns the string "active" if the given Controller name or action matches the current Route. Useful for Views.
  *
  * @param string|array $needles
  * @param string|array $css_classes
  *
  * @return string
  */
 function is_active($needles, $css_classes = ['active'])
 {
     // Convert $needles to array
     if (!is_array($needles)) {
         $needles = [$needles];
     }
     // Convert $css_classes to array
     if (!is_array($css_classes)) {
         $css_classes = [$css_classes];
     }
     // Iterate over given needle
     foreach ($needles as $needle) {
         // Detect mode
         $mode = 'action';
         if (strpos($needle, '@') === false) {
             $mode = 'controller';
         }
         // Get current Route and Action
         $route = Route::getCurrentRoute();
         $action = $route->getAction();
         $controller_namespaced = $action['controller'];
         // e.g. App\Http\Controllers\FooController@index
         $namespace = $action['namespace'];
         // e.g. App\Http\Controllers
         // Remove namespace from controller (+ 1 also removes leading backslash)
         $controller = substr($controller_namespaced, strspn($namespace, $controller_namespaced) + 1);
         switch ($mode) {
             case 'action':
                 // If $needle matches $controller return whitespace glued $css_classes
                 if ($needle === $controller) {
                     return implode(' ', $css_classes);
                 }
                 break;
             case 'controller':
                 // Remove the action part from $controller "...@index"
                 $controller_name = explode('@', $controller);
                 // If $needle matches $controller_name return whitespace glued $css_classes
                 if (isset($controller_name[0]) && $controller_name[0] == $needle) {
                     return implode(' ', $css_classes);
                 }
                 break;
         }
     }
     // Return empty string by default
     return '';
 }
Exemplo n.º 22
0
 public function rules()
 {
     $method = $this->method();
     $route = \Route::getCurrentRoute()->getPath();
     switch ($method) {
         case 'GET':
         case 'DELETE':
             return [];
         case 'POST':
             return ['distance_from' => 'required', 'distance_to' => 'required', 'radius' => 'required'];
         case 'PUT':
             return ['distance_from' => 'required' . \Request::input('radius_id'), 'distance_from' => 'required', 'radius' => 'required'];
         case 'PATCH':
         default:
             break;
     }
 }
Exemplo n.º 23
0
 public function rules()
 {
     $method = $this->method();
     $route = \Route::getCurrentRoute()->getPath();
     switch ($method) {
         case 'GET':
         case 'DELETE':
             return [];
         case 'POST':
             return ['make' => 'required|unique:car_make'];
         case 'PUT':
             return ['email' => 'unique:car_make,make,' . \Request::input('make_id')];
         case 'PATCH':
         default:
             break;
     }
 }
Exemplo n.º 24
0
 public function rules()
 {
     $method = $this->method();
     $route = \Route::getCurrentRoute()->getPath();
     switch ($method) {
         case 'GET':
         case 'DELETE':
             return [];
         case 'POST':
             return ['email' => 'required|unique:subscribers', 'ip' => 'required'];
         case 'PUT':
             return ['email' => 'unique:subscribers,email,' . \Request::input('subscriber_id'), 'ip' => 'required'];
         case 'PATCH':
         default:
             break;
     }
 }
Exemplo n.º 25
0
 function tableModel($collection, $modelName, $hasDelete = true, $hasEdit = true, $hasAdd = true, $hasModal = false)
 {
     $model = new $modelName();
     $data['prettyFields'] = $model->getPublicFields();
     $data['collection'] = $collection;
     $ruta = \Route::getCurrentRoute();
     $data['url'] = url($ruta->getPath());
     $data['hasEdit'] = $hasEdit;
     $data['hasDelete'] = $hasDelete;
     $data['hasAdd'] = $hasAdd;
     $data['hasModal'] = $hasModal;
     if ($hasAdd) {
         $data['urlAdd'] = $data['url'] . '/modificar';
         $data['nombreAdd'] = $model->getPrettyName();
     }
     return \View::make('templates.bootstrap.table', $data);
 }
Exemplo n.º 26
0
 public function rules()
 {
     $method = $this->method();
     $route = \Route::getCurrentRoute()->getPath();
     switch ($method) {
         case 'GET':
         case 'DELETE':
             return [];
         case 'POST':
             return ['currency' => 'required|unique:currency', 'symbol' => 'required'];
         case 'PUT':
             return ['currency' => 'unique:currency,currency,' . \Request::input('id'), 'symbol' => 'required'];
         case 'PATCH':
         default:
             break;
     }
 }
Exemplo n.º 27
0
 /**
  * Return the header title for each page
  *
  * @return string
  */
 function header_title()
 {
     $route = Route::currentRouteName();
     $title = '<h1>';
     $title .= trans(Route::getCurrentRoute()->getName());
     if (strpos($route, 'index') !== false) {
         $new = substr($route, 0, strrpos($route, '.') + 1) . 'create';
         if (Route::has($new)) {
             $title .= '<small>';
             $title .= '<a href="' . route($new) . '" title="' . trans($new) . '">';
             $title .= '<i class="fa fa-plus"></i>';
             $title .= '</a>';
             $title .= '</small>';
         }
     }
     $title .= '</h1>';
     return $title;
 }
Exemplo n.º 28
0
 public function getIndex()
 {
     $data['tipoeventos'] = \Oracle\TipoEvento::all();
     $picks = \Defeventosasyc::select('tipo_doc')->get();
     if ($picks->isEmpty()) {
         $data['evento'] = null;
     } else {
         foreach ($picks as $todo) {
             $arreglo = $todo['attributes'];
             $primero = array_shift($arreglo);
             $prueba[] = $primero;
             $data['evento'] = $prueba;
         }
     }
     $ruta = \Route::getCurrentRoute();
     $data['url'] = url($ruta->getPath());
     return \View::make('administracion.tablas.tipoEventos', $data);
 }
Exemplo n.º 29
0
 public function rules()
 {
     $method = $this->method();
     $route = \Route::getCurrentRoute()->getPath();
     switch ($method) {
         case 'GET':
         case 'DELETE':
             return [];
         case 'POST':
             return ['template_name' => 'required|unique:email_templates', 'subject' => 'required', 'template' => 'required', 'status' => 'required'];
             //}
         case 'PUT':
             return ['template_name' => 'unique:email_templates,template_name,' . \Request::input('id'), 'subject' => 'required', 'template' => 'required', 'status' => 'required'];
         case 'PATCH':
         default:
             break;
     }
 }
Exemplo n.º 30
0
 public static function getPath()
 {
     $datas = explode("/", \Route::getCurrentRoute()->getPath());
     $hitung = count($datas);
     $html = "";
     if ($hitung >= 1) {
         foreach ($datas as $data) {
             if ($data == "{dir}") {
                 $url = explode("/", \Request::url());
                 $bas = count($url);
                 $html .= '<a href="#" class="btn btn-default">' . $url[$bas - 1] . '</a>';
             } else {
                 $html .= '<a href="#" class="btn btn-default">' . $data . '</a>';
             }
         }
         return $html;
     } else {
         return $html;
     }
 }