/** * @param $value * * @return $this */ function add($as, $style = 'bg-aqua', $is_curtain = false, $params = []) { // debug_print_backtrace(); // dd(1); if (!Route::isEnable($as)) { return $this; } if (is_string($as) && !count(Route::get($as))) { // dd($as, Route::get($as)); return $this; } $this->children[$as] = ['class' => $style, 'curtain' => $is_curtain, 'params' => $params]; return $this; }
function addBreadCrumb($as = null, $replaced = []) { $this->replaced = array_merge($this->replaced, $replaced); $h1_ext = Route::get_h1_ext($as); $title = Route::get_title($as); $url = Route::get_url($as); foreach ($this->replaced as $k => $v) { $k = '{' . $k . '}'; $h1_ext = str_replace($k, $v, $h1_ext); $title = str_replace($k, $v, $title); $url = str_replace($k, $v, $url); } WidgetH1::factory()->setH1($title)->setH1Ext($h1_ext); WidgetMetaTags::factory()->setDescription($h1_ext); \Larakit\Page\Page::addBreadCrumb($title, $url); }
/** * @param $access_name * @param $text * @param $url * @param array $attrs * * @return $this */ function addItem($as, $key, $attrs = []) { if (!Route::isEnable($as)) { return $this; } if (is_array($as)) { $text = Arr::get($as, 'title'); $icon = Arr::get($as, 'icon'); $url = Arr::get($as, 'url', '#'); $as = Arr::get($as, 'as'); } else { $text = Route::get_title($as); $icon = Route::get_icon($as); $url = Route::get_url($as); } if ($icon) { $text = \HtmlI::setTitle($text)->addClass($icon) . ' ' . \HtmlSpan::setContent($text); } $this->map->add($key, $as, $text, $url, $attrs); return $this; }
/** * @param $access_name * @param $text * @param $url * @param array $attrs * * @return $this */ function addItem($as, $key, $route_parameters = []) { if (is_string($as)) { if (!Route::isEnable($as)) { return $this; } if (Route::checkRouteFilters($as)) { return $this; } if (!count(Route::get($as))) { return $this; } } if (is_array($as)) { $text = Arr::get($as, 'title'); $icon = Arr::get($as, 'icon'); $url = Arr::get($as, 'url', '#'); $as = Arr::get($as, 'as'); } else { $keys = array_keys($route_parameters); $keys = array_map(function ($item) { return '{' . $item . '}'; }, $keys); $text = str_replace($keys, array_values($route_parameters), Route::get_title($as)); $icon = Route::get_icon($as); $url = \URL::route($as, $route_parameters); } if ($icon) { $text = \HtmlI::setTitle($text)->addClass($icon) . ' ' . \HtmlSpan::setContent($text); } if (!isset($this->maps[$this->section])) { $this->maps[$this->section] = Map::instance(get_called_class() . $this->name . $this->section); } if ($route_parameters) { $key .= '.' . str_replace(['&', '='], ['.', '-'], http_build_query($route_parameters)); } $this->maps[$this->section]->add($key, $as, $text, $url); return $this; }
static function getRouteByUri($uri) { $uri = parse_url($uri, PHP_URL_PATH); $routes = []; foreach (\Route::getRoutes()->getRoutes() as $route) { $routes[$route->getUri()] = $route->getName(); } krsort($routes); // dd($routes); $uri = trim($uri, '/'); if (!$uri) { return 'home'; } $matched = false; $_m = []; $max = null; foreach ($routes as $route_uri => $name) { /** @var \Illuminate\Routing\Route $route */ $route_uri = preg_replace('/\\/\\{(.*)\\?\\}/U', '*', $route_uri); $route_uri = preg_replace('/\\*\\*/U', '*', $route_uri); $route_uri = preg_replace('/\\{(.*)\\}/U', '*', $route_uri); //dump($route_uri . ' | ' . $matched . ' | ' . $max); if (\Illuminate\Support\Str::is($route_uri, $uri)) { $_m[] = [$name, $route_uri]; $m = mb_substr_count($route_uri, '{'); if (is_null($max) || !$m || $m < $max) { $max = $m; $matched = $name; } } } //dump($_m); return $matched; }
<?php \Route::pattern('block', '[\\w\\d-_]+'); \Route::pattern('page', '[\\w\\d-_]+'); //**************************************** // Главная //**************************************** \Larakit\Route\Route::item('makeup')->setBaseUrl('/makeup')->setNamespace('Larakit\\Makeup\\Controller')->put(); \Larakit\Route\Route::item('makeup/download')->setBaseUrl('/makeup/download')->setNamespace('Larakit\\Makeup\\Controller')->setController('Makeup')->setAction('download')->put(); \Larakit\Route\Route::item('makeup/block')->setBaseUrl('/makeup/block-{block}')->setNamespace('Larakit\\Makeup\\Controller')->setController('Makeup')->setAction('block')->put(); \Larakit\Route\Route::item('makeup/page')->setBaseUrl('/makeup/page-{page}')->setNamespace('Larakit\\Makeup\\Controller')->setController('Makeup')->setAction('page')->put(); \Larakit\Route\Route::item('makeup/frame_block')->setBaseUrl('/makeup/frame-block-{block}')->setNamespace('Larakit\\Makeup\\Controller')->setController('Makeup')->setAction('frameBlock')->put(); \Larakit\Route\Route::item('makeup/frame_page')->setBaseUrl('/makeup/frame-page-{page}')->setNamespace('Larakit\\Makeup\\Controller')->setController('Makeup')->setAction('framePage')->put();
/** * @param $url * @param array $replacements * * @return $this */ function addBreadCrumb($route_name, $params = [], $replacements = []) { $url = route($route_name, $params, false); $title = \LaraPage::pageTitle($route_name, $replacements); $h1 = \LaraPage::pageH1($route_name, $replacements); $h1_ext = \LaraPage::pageH1Ext($route_name, $replacements); $description = \LaraPage::pageH1Ext($route_name, $replacements); $icon = Route::routeIcons($route_name); $this->breadcrumbs[$url] = compact('title', 'icon'); $this->setUrl($url); $_title = []; foreach ($this->breadcrumbs as $url => $breadcrumb) { $_title[] = Arr::get($breadcrumb, 'title'); } $_title = array_reverse($_title); $this->setTitle(implode(', ', $_title))->setDescription($description); return $this; }
<?php \Larakit\CRUD\CrudRow::register(\Larakit\Models\Entity::class, '/admincp/entities'); define('ROUTE_ADMIN_CODEGEN', 'larakit::admin.codegen'); \Larakit\Route\Route::item(ROUTE_ADMIN_CODEGEN)->setBaseUrl('/admincp/generator')->put()->addSegment('{model}')->put(); define('ROUTE_ADMIN', 'larakit::admin'); \Larakit\Route\Route::item(ROUTE_ADMIN)->setBaseUrl('/admincp/')->put(); \Adminlte\Widget\WidgetSidebarMenu::group('ГЕНЕРАТОР КОДА')->addItem('codegen', 'Модели', ROUTE_ADMIN_CODEGEN); return; $ret = []; foreach (Schema::getColumnListing('bmmaket-core__recommend_groups') as $name) { $ret[$name] = Schema::getColumnType('bmmaket-core__recommend_groups', $name); } dd($ret); dd(DB::table('bmmaket-core__recommend_groups'));
/** * Execute the console command. * * @return mixed */ public function fire() { $rows = []; $real_progress = 0; $idx = 0; $last = null; $items = []; foreach (\Route::getRoutes() as $r => $route) { // if (!\Larakit\Route\Route::isEnable($route->getName())) { // continue; // } /** * @var Route $route */ $item = []; $action = $route->getActionName(); $_action = explode('@', $action); $method = Arr::get($_action, 1); $class = Arr::get($_action, 0); // if (($action != 'Closure') && (strpos($action, 'Larakit') === false)) // continue; if ('Closure' == $action) { $progress = 100; } else { if (is_callable(explode('@', $action))) { $readiness = (int) \Larakit\Route\Route::_($route->getName(), 'readiness'); if (!$readiness) { $readiness = 1; } $progress = $readiness; } else { $progress = 0; } } $idx++; $real_progress += $progress; switch (true) { case $progress < 50: $style = 'error'; break; case $progress < 100: $style = 'question'; break; default: $style = 'info'; break; } $item[] = $this->wrap($route->domain(), $style); $item[] = $this->wrap(implode('|', $route->getMethods()), $style); $item[] = $this->wrap($route->getUri(), $style); $item[] = $this->wrap($route->getName(), $style); if ('Closure' == $action) { $item[] = $this->wrap('\\Closure', $style); $item[] = ''; } else { $item[] = $this->wrap($class, $style); $item[] = $this->wrap($method, $style); } $item[] = $this->wrap($idx, $style, 3); $item[] = $this->wrap($progress . '%', $style, 9); $v = mb_strpos($route->getName(), '::') ? explode('::', $route->getName()) : []; $vendor = Arr::get($v, 0, 'app'); // $item[] = $vendor; if ($last != $vendor) { if (!is_null($last)) { $rows[] = new TableSeparator(); } $last = $vendor; } $items[$route->getName()] = $item; } $last = null; $rows = []; $idx = 0; foreach ($items as $route => $row) { $idx++; $v = mb_strpos($route, '::') ? explode('::', $route) : []; $vendor = Arr::get($v, 0, 'app'); if ($last != $vendor) { if (!is_null($last)) { $rows[] = new TableSeparator(); } $last = $vendor; } $rows[] = [$idx] + $row; } // foreach($) $this->table(['Domain', 'Method', 'URI', 'RouteName', 'Controller', 'Action', '#', 'Readiness'], $rows); $progress_all = count($rows) * 100; $real_progress = $real_progress / $progress_all * 100; $this->info('Общая готовность: ' . number_format($real_progress, 2) . '%'); $this->info('[' . str_pad(str_repeat('#', (int) $real_progress) . ($real_progress != 100 ? '>' : ''), 100, '-', STR_PAD_RIGHT) . ']'); }
<?php /** * Created by Larakit. * Link: http://github.com/larakit * User: Alexey Berdnikov * Date: 29.06.16 * Time: 9:37 */ \Larakit\Twig::register_function('icon_by_route', function ($route_name) { return \Larakit\Route\Route::routeIcons($route_name); });