make($abstract, $arguments); } } if(!function_exists('csrf_token')) { /** * @return string|null */ function csrf_token(): ?string { $baseVerifier = Router::router()->getCsrfVerifier(); if ($baseVerifier !== null) { return $baseVerifier->getTokenProvider()->getToken(); } return null; } } if(!function_exists('dump')) { function dump(...$params) { echo '
'; foreach ($params as $param) { var_dump($param); } echo ''; } } if(!function_exists('endsWith')) { /** * @param $haystack * @param $needle * @return bool */ function endsWith($haystack, $needle) { $length = strlen($needle); if ($length == 0) { return true; } return (substr($haystack, -$length) === $needle); } } if(!function_exists('input')) { /** * @param string|null $index Parameter index name * @param string|null $defaultValue Default return value * @param array ...$methods Default methods * @return InputHandler|array|string|null */ function input($index = null, $defaultValue = null, ...$methods) { if ($index !== null) { return request()->getInputHandler()->value($index, $defaultValue, ...$methods); } return request()->getInputHandler(); } } if(!function_exists('redirect')) { /** * @param string $url * @param int|null $code */ function redirect(string $url, ?int $code = null): void { if ($code !== null) { response()->httpCode($code); } response()->redirect($url); } } if(!function_exists('response')) { /** * @return Response */ function response(): Response { return Router::response(); } } if(!function_exists('request')) { /** * @return Request */ function request(): Request { return Router::request(); } } if(!function_exists('route')) { /** * @param string|null $name * @param string|array|null $parameters * @param array|null $getParams * @return Url */ function route(?string $name = null, $parameters = null, ?array $getParams = null): Url { return Router::getUrl($name, $parameters, $getParams); } } if(!function_exists('startsWith')) { /** * @param $haystack * @param $needle * @return bool */ function startsWith($haystack, $needle) { $length = strlen($needle); return (substr($haystack, 0, $length) === $needle); } } if(!function_exists('view')) { /** * @param $name * @param array $arguments * @return mixed */ function view($name, $arguments = []) { $factory = app(ViewFactory::class); return $factory->make($name, $arguments); } }