public function testApplicationLogout() { /* * Laravel 5.3's logout route redirects to '/' * Easel does not provide a '/' route by default so for the purpose of testing * Create a test route so that the logout redirects properly */ if (!\Route::has('/')) { \Route::get('/', '\\Easel\\Http\\Controllers\\Frontend\\BlogController@index'); } $this->actingAs($this->user)->seeIsAuthenticatedAs($this->user)->visit('/admin/post')->click('Sign out')->seePageIs('/')->dontSeeIsAuthenticated(); }
/** * Create a URL Based from a route $name * @param type $name * @param type $params */ function zbase_url_from_route($name, $params = [], $relative = false) { if (!\Route::has($name)) { return '#'; } $routes = zbase_config_get('routes'); $prefix = ''; $name = str_replace('admin.', zbase_admin_key() . '.', $name); $name = str_replace('admin', zbase_admin_key(), $name); $usernameRouteEnabled = zbase_route_username(); if (isset($routes[$name]['usernameroute'])) { if ($routes[$name]['usernameroute'] === false) { $usernameRouteEnabled = false; } } if (!empty($usernameRouteEnabled)) { $usernameRouteParameterName = zbase_route_username_prefix(); $usernameRoute = zbase_route_username_get(); $username = zbase_route_input(zbase_route_username_prefix(), false); if (!empty($username)) { $username = strtolower($username); $user = zbase_user_by('username', $username); if ($user instanceof \Zbase\Entity\Laravel\User\User && $user->hasUrl()) { $usernameRoute = true; } } if (empty($usernameRoute) && zbase_auth_has() && zbase_is_back()) { $username = zbase_auth_user()->username(); $usernameRoute = true; } if (!empty($usernameRoute)) { $prefix = $usernameRouteParameterName; if (empty($params[$usernameRouteParameterName])) { $params[$usernameRouteParameterName] = $username; } } } $name = $prefix . $name; if (!empty($relative)) { $home = route('index'); $url = str_replace($home, '', route($name, $params)); } else { $url = route($name, $params); } if ($usernameRouteEnabled && !empty($usernameRoute)) { $url = str_replace($usernameRoute . '/' . $usernameRoute, '/' . $usernameRoute . '/', $url); } return $url; }
/** * Return route name, given current url, depending of language * * @param string $lang * @return string */ function get_lang_route($lang) { // get parameters from url route $parameters = Request::route()->parameters(); $routeName = Request::route()->getName(); $originRoute = substr($routeName, 0, strlen($routeName) - 2); if (Route::has($originRoute . $lang)) { return route($originRoute . $lang, $parameters); } else { // check if exist any route with language code if (Route::has($routeName . '-' . $lang)) { return route($routeName . '-' . $lang, $parameters); } else { return route($routeName, $parameters); } } }
function addRelation($relation, $data, $subrelation) { $has_many = Arr::get($data, 'has_many', $relation); $title = Arr::get($data, 'title'); $js_filters = (array) Arr::get($data, 'js_filters'); $base_route = Arr::get($data, 'base_route'); $row_type = Arr::get($data, 'row_type', 'admin'); try { $r = $this->model->{$has_many}(); if (!is_object($r)) { throw new \Exception('Нет связи ' . $has_many); } $relation_model_class = get_class($r->getRelated()); // $this->add('errors', $relation_model_class); $ret['relation_model_class'] = $relation_model_class; $ret['models'] = $this->model->{$relation}; $ret['title'] = $title ? $title : $relation_model_class::getEntityNameCasePlural(); // $this->add('errors', $ret['name']); $ret['js_filters'] = implode(' ', $js_filters); // $this->add('errors', $section); // if($base_route){ // $ret['entity'] = $relation_model_class::getEntity(); // $ret['vendor'] = $relation_model_class::getVendor(); // } else { $ret['entity'] = Arr::get($data, 'entity', $relation_model_class::getEntity()); $ret['vendor'] = Arr::get($data, 'vendor', $relation_model_class::getVendor()); // } $ret['with'] = array_keys($subrelation); $ret['base_route'] = $base_route; $ret['row_type'] = $row_type; $belongsto_class = $this->get('belongsto.class'); $model = $this->get('belongsto.model'); $route_name = $base_route . '.add'; if (\Route::has($route_name)) { if (!$relation_model_class::getAcl()->reason('add')) { $ret['add_url'] = \URL::route($route_name, [$belongsto_class::getEntity() . '_id' => $model->id]); } } $this->add('relations', $ret); } catch (\Exception $e) { $this->add('errors', [$relation, $data, $subrelation]); $this->add('errors', $e->getMessage()); } return $this; }
/** * 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; }
/** * @param $template * * @return string * * @throws \Exception */ public function render_model($template) { if ($this->options['image_uploads'] || $this->options['file_uploads']) { if ($this->options['image_uploads']) { $this->modelReplacements[':uses'][] = UploadImageInterface::class; $this->modelReplacements[':implementations'][] = class_basename(UploadImageInterface::class); $this->modelReplacements[':uses'][] = AdminImage::class; $this->modelReplacements[':traits'][] = class_basename(AdminImage::class); } if ($this->options['file_uploads']) { $this->modelReplacements[':uses'][] = UploadFileInterface::class; $this->modelReplacements[':implementations'][] = class_basename(UploadFileInterface::class); $this->modelReplacements[':uses'][] = AdminFile::class; $this->modelReplacements[':traits'][] = class_basename(AdminFile::class); } } $this->modelReplacements[':app_namespace'] = $this->getAppNamespace(); $this->modelReplacements[':table_name'] = str_plural($this->identifier); $this->modelReplacements[':model_name'] = $this->command->model_name($this->identifier); $this->modelReplacements[':identifier'] = $this->identifier; $this->prepareReplacements(); // Check to see if route is not already used if (\Route::has($this->identifier . '.index')) { // Check if admin is also free if (\Route::has('admin.' . $this->identifier . '.index')) { throw new \Exception('Resource `' . $this->identifier . '` already exists'); } // We need to append admin foreach ($this->routeActions as $action) { $this->routeNames[$action] = 'admin.' . $this->identifier . '.' . $action; } } $route = "Route::resource('{$this->identifier}', 'Admin\\" . $this->command->controller_name($this->identifier) . "'"; if (!empty($this->routeNames)) { // create the resource names $route .= ',[' . PHP_EOL . "'names' => [" . PHP_EOL; foreach ($this->routeNames as $action => $name) { $route .= "'{$action}' => '{$name}'," . PHP_EOL; } $route .= ']' . PHP_EOL . ']);' . PHP_EOL; } else { // Close the Route resource $route .= ');' . PHP_EOL; } if ($this->options['file_uploads']) { $route .= "Route::get('{$this->identifier}/delete/{fileFieldName}', 'Admin\\" . $this->command->controller_name($this->identifier) . "@deleteFile');" . PHP_EOL; } $this->appendToFile(base_path('routes/resources.php'), $route); $template = strtr($template, $this->modelReplacements); return $template; }
<html> <head> <script src="//api-maps.yandex.ru/2.0/?load=package.standard,package.geoObjects&lang=ru-RU" type="text/javascript"></script> <script src="/js/map.js" type="text/javascript"></script> <?php echo View::make('layouts.inc.head.head'); ?> </head> <body> <div class="container"> <div><img src="/assets/main/logo.png" border="0" width="370" height="175" class="img" /></div> <div class="row text-center"> <h2> [cайт на стадии разработки] <a href="/vanguard">[программа стажировки]</a> <?php if (Route::has('qiwiGate_about')) { ?> <a href="<?php echo URL::route('qiwiGate_about'); ?> ">[эмулятор qiwi]</a> <?php } ?> </h2> </div> <div class="row mt20"> <div class="col-xs-6"> <p><b>FINTECH_FAB</b> — высокотехнологичная компания на рынке финансовых технологий.</p>
<?php /* |-------------------------------------------------------------------------- | Route to Jaxon request processor |-------------------------------------------------------------------------- | | All Jaxon requests are sent through this route to the JaxonController class. | */ $route = config('jaxon.app.route', 'jaxon'); if (!Route::has($route)) { Route::post($route, array('as' => 'jaxon', 'uses' => '\\Jaxon\\Laravel\\Http\\Controllers\\JaxonController@process')); }
/** * This will generate a url relating to the given route, whether that is * from a raw url or if it is a route. It will also grab the params for * the values. * * @param string $route * @param mixed $params * * @return string */ protected function generateLink($route, $params = null) { if ($route instanceof Closure) { // Have to stringify this before calling Route::has because it will // Fail if we don't pass a string in $route = $this->stringify($route); } if (\Route::has($route)) { // If params is empty, just don't call it... if (empty($params)) { return route($this->routify($route)); } else { // Since $params isn't empty and $route is a Route, just paramify both. return route($this->routify($route), $this->routeparamify($params)); } } if (empty($params)) { return url($this->routify($route)); } else { // Since $params isn't empty and $route is not Route, just paramify both anyway. return url($this->routify($route), $this->routeparamify($params)); } }
/** * @param null $url URL or route name * @param array $params optional url / route params * @return mixed */ public function back_url($url = null, $params = []) { if (is_null($url)) { return is_null($this->back_url) ? session('_redirectBack', URL::previous()) : $this->back_url; } if (\Route::has($url)) { $this->back_url = route($url, $params); } else { $this->back_url = url($url, $params); } return $this; }
function has_route($name) { return \Route::has($name); }
if (Route::has('qiwiShop_aboutSdk')) { ?> <li class="act"> <a href="<?php echo URL::route('qiwiShop_aboutSdk'); ?> ">PHP SDK</a> </li> <?php } ?> </ul> <ul class="nav navbar-nav navbar-right"> <?php if (Route::has('registration')) { if (Config::get('ff-qiwi-gate::user_id') > 0) { ?> <li><a class="top-link" href="/logout"><i class="fa fa-sign-out"></i> Logout</a></li><?php } else { ?> <li><a class="top-link" href="<?php echo Helper::url2Sign(); ?> "><i class="fa fa-sign-in"></i> Sign-in</a> </li><?php } } ?> </ul>
<?php /** * @var int $user_id */ $callbackUrl = Route::has('qiwiShop_processCallback') ? URL::route('qiwiShop_processCallback') : ''; ?> <script type="application/javascript"> <?php require __DIR__ . '/../layouts/inc/js/ActionAccountReg.js'; ?> </script> <div id="message"></div> <div class="col-sm-offset-3 col-md-6 inner"> <div class="content"> <h2 class="text-center">Регистрация в системе QIWI</h2> <div class="form-group row"> <label for="inputId" class="col-sm-3 control-label">Ваш ID (логин)</label> <div class="col-sm-7"> <?php echo Form::input('text', 'userId', $user_id, array('class' => 'form-control', 'id' => 'inputId', 'required' => '', 'disabled' => '')); ?> </div> <div class="text-danger" id="errorId"></div> </div> <div class="form-group row"> <label for="inputUsername" class="col-sm-3 control-label">Имя</label> <div class="col-sm-7">
/** * Render Menu. * * @param string/Menu $groupName * @param array $config * * @return void */ function renderMenu($groupName, $config = [], $first = true) { $render = ''; if (is_string($groupName)) { $nested = Menu::whereGroupName($groupName)->orderBy('lft')->get(); if (!$nested) { return; } $menus = $nested->toHierarchy(); } else { $menus = $groupName; } foreach ($menus as $menu) { if ($menu->type == 'page') { $page = Page::find($menu->link); $url = $page ? route('page.show', $page->shortcut) : '#'; } elseif ($menu->type == 'route') { $url = Route::has($menu->link) ? route($menu->link) : '#'; } else { $url = starts_with($menu->link, '/') ? url($menu->link) : $menu->link; } $active = url()->current() == $url ? 'active' : ''; $hasChildren = $menu->children()->count() > 0; $element = $first ? 'parent' : 'children'; $attrType = $hasChildren ? 'withChildren' : 'withoutChildren'; $li = str_replace('{active}', $active, array_get($config, $element . '.li.' . $attrType, 'class="{active}"')); $liChildren = array_get($config, $element . '.liChildren'); $link = array_get($config, $element . '.link.' . $attrType); $ul = array_get($config, $element . '.ul'); $caret = $hasChildren ? array_get($config, $element . '.angle', '<span class="caret"></span>') : ''; $render .= '<li ' . $li . '>' . ' <a href="' . $url . '" ' . $link . '>' . ' <i class="' . $menu->icon . '"></i> ' . $menu->name . ' ' . $caret . ' </a>'; if ($hasChildren) { $render .= '<ul ' . $ul . '>'; $render .= renderMenu($menu->children, $config, false); $render .= '</ul>'; } $render .= '</li>'; } return $render; }
/** * @param string|array $hackRoute * @return boolean */ function hasPermission($hackRoute) { if (is_array($hackRoute)) { foreach ($hackRoute as $route) { if (hasPermission($route)) { return true; } } return false; } $prefixes = ['admin', 'api']; $route = hackToRoute($hackRoute); $routePrefix = explode('.', $route)[0]; if (!in_array($routePrefix, $prefixes) || Route::has($route) && (!is_null(\Sentinel::getUser()) && (\Sentinel::getUser()->is_super_admin || \Sentinel::hasAccess($hackRoute)))) { return true; } return false; }