我在控制器的特定功能中返回视图时遇到了一些问题.
即使在这个控制器中,我的所有视图都在我的应用程序中随处可见.当我尝试返回任何视图,包括我可以返回其他地方的测试视图时,我总是在一个空白页面上.我的日志(PHP和Apache)是空的.
调节器
function firstfct($path){
$obj = new Foo\Bar($this);
$obj->Insert($path);
}
function ReturnsBlank(){
//Fetching some variables that I was able to dump
return \View::make('test'); //Blank
//return var_dump('FooBar'); // Returns "FooBar"
}
Run Code Online (Sandbox Code Playgroud)
Foo/bar文件
class SomeClass{
protected $listener;
public function __construct($listener)
{
$this->listener = $listener;
}
function Insert($path){
//Some stuff that it is working well
return $this->listener->ReturnsBlank();
}
}
Run Code Online (Sandbox Code Playgroud)
test.blade.php
<pre>
Done!
</pre>
<hr/>
Run Code Online (Sandbox Code Playgroud)
问题是你的firstfct控制器实际上没有向Laravel"返回"任何东西.视图被'返回'到函数firstfct - 但是你需要传递它
更改
function firstfct($path){
$obj = new Foo\Bar($this);
$obj->Insert($path);
}
Run Code Online (Sandbox Code Playgroud)
至
function firstfct($path){
$obj = new Foo\Bar($this);
return $obj->Insert($path);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2771 次 |
| 最近记录: |