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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?