php - Laravel view rendering issue
288
Following is my controller class,
namespace Admin;
class CategoriesController extends \BaseController {
public function index($action = '', $id= ''){
//return \View::make('welcome');View is correctly rendered here
switch ($action){
case '' :
case 'list' : $this->showList();
break;
case 'add' : $this->addCategories();
break;
case 'edit' : $this->editCategories($id);
break;
}
}
public function showList($id_category =''){
echo "testing";
return \View::make('welcome'); //it does not work here
}
While calling the view, it does not work within the function showList(). The echo inside the function works, but the view just return a blank page without any errors. What could be the issue here?
Answer
Solution:
I imagine you want to call
showList
from theindex
function and not from the routes. If so, there's no return action from theindex
function. In order to make it work, you need to return within theindex
function what is returned fromshowList
function, otherwise, the View will not be rendered. Try changing yourindex
function to:Answer
Solution:
here is the problem...remove the / from the return view line
}