本文整理汇总了PHP中Illuminate\Routing\Redirector::to方法的典型用法代码示例。如果您正苦于以下问题:PHP Redirector::to方法的具体用法?PHP Redirector::to怎么用?PHP Redirector::to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Routing\Redirector
的用法示例。
在下文中一共展示了Redirector::to方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filter
public function filter(Route $route, Request $request)
{
if ($this->auth->check()) {
$config = $this->config->get('c::redirect-login');
$url = $config ? $this->url->to($config) : '/';
return $this->redirect->to($url);
}
}
示例2: makeResponse
protected function makeResponse(Request $request)
{
$message = $this->translator->get('c::auth.login-required');
if ($request->ajax() || $request->isJson() || $request->wantsJson()) {
return Response::json(['error' => $message], 403);
} else {
$url = $this->url->action('anlutro\\Core\\Web\\AuthController@login');
$intended = $request->getMethod() == 'GET' ? $request->fullUrl() : ($request->header('referer') ?: '/');
$this->session->put('url.intended', $intended);
return $this->redirect->to($url)->with('error', $message);
}
}
示例3: handle
/**
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$this->authenticator->isAuthenticated()) {
return $this->redirector->to($this->config->get('littlegatekeeper.authRoute'));
}
return $next($request);
}
示例4: response
/**
* Get the proper failed validation response for the request.
*
* @param array $errors
* @return \Symfony\Component\HttpFoundation\Response
*/
public function response(array $errors)
{
if ($this->ajax() || $this->wantsJson()) {
return new JsonResponse($errors, 422);
}
return $this->redirector->to($this->getRedirectUrl())->withInput($this->except($this->dontFlash))->withErrors($errors, $this->errorBag);
}
示例5: create
/**
* Create a new Redirect response.
*
* @param RedirectInterface $redirect
* @return \Illuminate\Http\RedirectResponse
*/
public function create(RedirectInterface $redirect)
{
$parameters = array_merge(array_map(function () {
return null;
}, array_flip($this->route->parameterNames())), $this->route->parameters());
return $this->redirector->to($this->parser->parse($redirect->getTo(), $parameters), $redirect->getStatus(), [], $redirect->isSecure());
}
示例6: handle
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if (!$request->isSecure()) {
return $this->redirector->to($request->getRequestUri(), 302, $request->headers->all(), true);
}
return $next($request);
}
示例7: select
/**
* @param $gamertag
* @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
*/
public function select($gamertag)
{
$players = destiny()->player($gamertag);
if ($players->count() == 1) {
return $this->redirect->to($players->first()->url);
}
return $this->view->make('select', ['gamertag' => $gamertag, 'players' => $players]);
}
示例8: view
/**
* Redirect to a post's URL.
*
* @param PostRepositoryInterface $posts
* @param Redirector $redirect
* @param $id
* @return \Illuminate\Http\RedirectResponse
*/
public function view(PostRepositoryInterface $posts, Redirector $redirect, $id)
{
/* @var PostInterface $post */
$post = $posts->find($id);
if (!$post->isLive()) {
return $redirect->to($this->dispatch(new GetPostPath($post)));
}
return $redirect->to($post->path());
}
示例9: view
/**
* Redirect to a partial's URL.
*
* @param PartialRepositoryInterface $partials
* @param Redirector $redirector
* @param $id
* @return \Illuminate\Http\RedirectResponse
*/
public function view(PartialRepositoryInterface $partials, Redirector $redirector, $id)
{
$first = $partials->first();
$partial = $partials->find($id);
// Redirect to home if this is the first partial.
if ($first && $first->getId() === $partial->getId()) {
return $redirector->to('/');
}
return $redirector->to($partial->path());
}
示例10: create
/**
* Create a new Redirect response.
*
* @param RedirectInterface $redirect
* @return \Illuminate\Http\RedirectResponse
*/
public function create(RedirectInterface $redirect)
{
$parameters = array_merge(array_map(function () {
return null;
}, array_flip($this->route->parameterNames())), $this->route->parameters());
if (!starts_with($url = $redirect->getTo(), ['http://', 'https://', '//'])) {
$url = $this->url->to($redirect->getTo(), [], $redirect->isSecure());
}
return $this->redirector->to(rtrim($this->parser->parse($url, $parameters), '/'), $redirect->getStatus());
}
示例11: redirect
/**
* Redirect elsewhere.
*
* @param PageRepositoryInterface $pages
* @param Redirector $redirector
* @param Route $route
* @return \Illuminate\Http\RedirectResponse|void
*/
public function redirect(PageRepositoryInterface $pages, Redirector $redirector, Route $route)
{
if ($to = array_get($route->getAction(), 'anomaly.module.pages::redirect')) {
return $redirector->to($to, array_get($route->getAction(), 'status', 302));
}
/* @var PageInterface $page */
if ($page = $pages->find(array_get($route->getAction(), 'anomaly.module.pages::page', 0))) {
return $redirector->to($page->getPath(), array_get($route->getAction(), 'status', 302));
}
abort(404);
}
示例12: view
/**
* Redirect to a page's URL.
*
* @param PageRepositoryInterface $pages
* @param Redirector $redirect
* @param $id
* @return \Illuminate\Http\RedirectResponse
*/
public function view(PageRepositoryInterface $pages, Redirector $redirect, $id)
{
/* @var PageInterface $page */
$page = $pages->find($id);
if (!$page->isEnabled()) {
return $redirect->to('pages/preview/' . $page->getStrId());
}
if ($page->isHome()) {
return $redirect->to('/');
}
return $redirect->to($page->getPath());
}
示例13: postIndex
/**
* Show the login form
*
* @return mixed
*/
public function postIndex()
{
// Pick up the honeypot field to stop bots, return to the login screen, no message
if ($this->request->get('potter')) {
return $this->redirect->to('auth/login')->withInput();
}
if (!$this->validator->with($this->request->all())->passes()) {
return $this->redirect->to('auth/login')->withErrors($this->validator->errors());
}
if ($this->auth->attempt(['username' => $this->request->get('username'), 'password' => $this->request->get('password')])) {
return $this->redirect->intended('/');
}
$this->session->flash('failed', trans('auth.incorrect_username_or_password'));
return $this->redirect->to('auth/login')->withInput();
}
示例14: connect
/**
* Connect the current user to Last.fm.
*
* @param Redirector $redirector
* @param Lastfm $lastfm
*
* @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
*/
public function connect(Redirector $redirector, Lastfm $lastfm)
{
if (!$lastfm->enabled()) {
abort(401, 'Koel is not configured to use with Last.fm yet.');
}
return $redirector->to('https://www.last.fm/api/auth/?api_key=' . $lastfm->getKey() . '&cb=' . route('lastfm.callback'));
}
示例15: postReset
public function postReset()
{
$credentials = $this->request->only('email', 'password', 'password_confirmation', 'token');
$response = $this->password->reset($credentials, function ($user, $password) {
$user->password = $this->hasher->make($password);
$user->save();
});
switch ($response) {
case $this->password->INVALID_PASSWORD:
case $this->password->INVALID_TOKEN:
case $this->password->INVALID_USER:
return $this->redirector->back()->with('error', $this->translator->get($response));
case $this->password->PASSWORD_RESET:
return $this->redirector->to('/');
}
}