Question

I'm having some problem returning a view in a specific function of my controller.

All my views are returning fine everywhere in my app, even in this controller. When I try to return any view, including test view that I can return somewhere else, I always end up on a blank page. My logs (PHP and Apache) are empty.

Controller

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"
}

The Foo/bar file

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();


 }
 }

test.blade.php

<pre>   
    Done!
</pre>
<hr/>
Was it helpful?

Solution

The problem is your firstfct controller is not actually 'returning' anything to Laravel. The view is 'returned' to the function firstfct - but you need to pass it on

Change

function firstfct($path){

 $obj = new Foo\Bar($this);
 $obj->Insert($path);

 }

to

function firstfct($path){

 $obj = new Foo\Bar($this);
 return $obj->Insert($path);

 }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top