public function redirectTo($key, array $message = [], $payload = [])
{
// A key can either be a string representing a config entry, or
// an array representing the "direction" we intend to go in.
$direction = is_array($key) ? $key : config('sentinel.routing.' . $key);
// Convert this "direction" to a url
$url = $this->generateUrl($direction, $payload);
// Determine if the developer has disabled HTML views
$views = config('sentinel.views_enabled');
// If the url is empty or views have been disabled the developer
// wants to return json rather than an HTML view.
if (!$url || !$views || Request::ajax() || Request::pjax()) {
return Response::json(array_merge($payload, $message));
}
// Do we need to flash any session data?
if ($message) {
$status = key($message);
$text = current($message);
Session::flash($status, $text);
}
// Redirect to the intended url
return Redirect::to($url)->with($payload);
}