doumei1203 2018-12-21 12:25
浏览 342
已采纳

Laravel不会返回视图

Currently I'm working on a Laravel project and I try to return a view in my controller. So far, so good.

But, when I really want to show the data from the view, nothing gots returned. It only shows a white screen.

So, what can be the problem? I don't know yet.

This is my current code

public function show(Domain $inputDomain)
    {
        $domainId = Domain::where('domain', $inputDomain->domain)->firstOrFail()->id;
        $scanId = Scan::where('domain_id', $domainId)->firstOrFail()->id;
        $result = Result::where('scan_id', $scanId)->firstOrFail();
        return view('detail');
    }

The last return does not work, it does not show the view.

Good to know:
1. When I just dump (dd) true, it works and I see the true-message
2. The view really exists and it contains data (I also tried to replace the blade template with some 'lorem ipsum' data, but also that did'nt show up)

When I just do a dd on the View::render (made an $view variable and did dd($view->render()) it shows me the HTML (in the DD screen), but when I return it, it is empty.

Comments

According to a comment I want to show the Route that I'm using

Route::get('{domain}', 'DomainController@scan');

According to a comment, I also want to show that I point to a file in the root of views/

views

How can I show the view to the visitor?

Also good to know, (forgot to mention) This is my @scan function

public function scan(Domain $domain)
    {
        Dispatch(new ProcessScan($domain));
        $this->show($domain);
    }
  • 写回答

1条回答 默认 最新

  • drflkphi675447 2018-12-21 12:41
    关注

    Found the problem

    I forgot to return the data in @scan

    Changed the code to

    public function scan(Domain $domain)
        {
            Dispatch(new ProcessScan($domain));
            return $this->show($domain); //Added return
        }
    

    And it is working

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记