����JFIF��x�x����'
Server IP : 66.29.137.217 / Your IP : 18.116.89.157 Web Server : LiteSpeed System : Linux premium294.web-hosting.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : gltevjme ( 1095) PHP Version : 7.0.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/gltevjme/./cbt.gltechlimited.com/vendor/tightenco/ziggy/src/ |
Upload File : |
<?php namespace Tightenco\Ziggy; use Illuminate\Contracts\Routing\UrlRoutable; use Illuminate\Support\Arr; use Illuminate\Support\Reflector; use Illuminate\Support\Str; use JsonSerializable; use ReflectionMethod; class Ziggy implements JsonSerializable { protected $port; protected $url; protected $group; protected $routes; public function __construct($group = null, string $url = null) { $this->group = $group; $this->url = rtrim($url ?? url('/'), '/'); $this->port = parse_url($this->url)['port'] ?? null; $this->routes = $this->nameKeyedRoutes(); } private function applyFilters($group) { if ($group) { return $this->group($group); } // return unfiltered routes if user set both config options. if (config()->has('ziggy.except') && config()->has('ziggy.only')) { return $this->routes; } if (config()->has('ziggy.except')) { return $this->filter(config('ziggy.except'), false)->routes; } if (config()->has('ziggy.only')) { return $this->filter(config('ziggy.only'))->routes; } return $this->routes; } /** * Filter routes by group. */ private function group($group) { if (is_array($group)) { $filters = []; foreach ($group as $groupName) { $filters = array_merge($filters, config("ziggy.groups.{$groupName}")); } return $this->filter($filters, true)->routes; } if (config()->has("ziggy.groups.{$group}")) { return $this->filter(config("ziggy.groups.{$group}"), true)->routes; } return $this->routes; } /** * Filter routes by name using the given patterns. */ public function filter($filters = [], $include = true): self { $this->routes = $this->routes->filter(function ($route, $name) use ($filters, $include) { return Str::is(Arr::wrap($filters), $name) ? $include : ! $include; }); return $this; } /** * Get a list of the application's named routes, keyed by their names. */ private function nameKeyedRoutes() { [$fallbacks, $routes] = collect(app('router')->getRoutes()->getRoutesByName()) ->reject(function ($route) { return Str::startsWith($route->getName(), 'generated::'); }) ->partition(function ($route) { return $route->isFallback; }); $bindings = $this->resolveBindings($routes->toArray()); return $routes->merge($fallbacks) ->map(function ($route) use ($bindings) { return collect($route)->only(['uri', 'methods']) ->put('domain', $route->domain()) ->put('bindings', $bindings[$route->getName()] ?? []) ->when($middleware = config('ziggy.middleware'), function ($collection) use ($middleware, $route) { if (is_array($middleware)) { return $collection->put('middleware', collect($route->middleware())->intersect($middleware)->values()->all()); } return $collection->put('middleware', $route->middleware()); })->filter(); }); } /** * Convert this Ziggy instance to an array. */ public function toArray(): array { return [ 'url' => $this->url, 'port' => $this->port, 'defaults' => method_exists(app('url'), 'getDefaultParameters') ? app('url')->getDefaultParameters() : [], 'routes' => $this->applyFilters($this->group)->toArray(), ]; } /** * Convert this Ziggy instance into something JSON serializable. */ public function jsonSerialize(): array { return array_merge($routes = $this->toArray(), [ 'defaults' => (object) $routes['defaults'], ]); } /** * Convert this Ziggy instance to JSON. */ public function toJson(int $options = 0): string { return json_encode($this->jsonSerialize(), $options); } /** * Resolve route key names for any route parameters using Eloquent route model binding. */ private function resolveBindings(array $routes): array { $scopedBindings = method_exists(head($routes) ?: '', 'bindingFields'); foreach ($routes as $name => $route) { $bindings = []; foreach ($route->signatureParameters(UrlRoutable::class) as $parameter) { $model = class_exists(Reflector::class) ? Reflector::getParameterClassName($parameter) : $parameter->getType()->getName(); $override = $model === (new ReflectionMethod($model, 'getRouteKeyName'))->class; // Avoid booting this model if it doesn't override the default route key name $bindings[$parameter->getName()] = $override ? app($model)->getRouteKeyName() : 'id'; } $routes[$name] = $scopedBindings ? array_merge($bindings, $route->bindingFields()) : $bindings; } return $routes; } }