doubaoxue5788 2019-04-15 13:33
浏览 99

如何将页面加载器放在laravel控制器的功能中?

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条回答 默认 最新

  • duanfen9983 2019-04-15 14:16
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度