问题
I am routing my user's to third party URL.
Now whenever they are routing there is a blank page or default tab which is open is displaying, but they are actually redirecting on that URL.
What i want to do like as soon as that routing first function called i need to put page loader there so user's come to know that they are redirecting.
How can i do that in controller ? I can load view file i know but after that remaining code will not work of that function.
Guide me over here.
Thanks in advance.
I tried loading view file but it was not run remaining code.
回答1:
Simply direct your users to a holding page, and then run some simple javascript redirects to get them to their actual destination.
app/routes/web.php
Route::get('redirect', 'YourController@redirect');
app/Http/Controllers/YourController.php
public function redirect(Request $request) {
$url = $request['url'];
return view('holding-page', compact('url'));
}
resources/views/holding-page.blade.php
<script type="text/javascript">
// Redirect the user to where they want to go after 3 seconds.
setTimeout(function() {
window.location.replace("{{ $url }}");
}, 3000);
</script>
Make sure you url encode any urls that you pass as a query string parameter.
https://yoursite.com/redirect?url=https%3A%2F%2Fstackoverflow.com
来源:https://stackoverflow.com/questions/55690369/how-can-i-put-page-loader-in-laravel-controllers-function