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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog