I'm starting with Laravel, seeing from the rails, where to return a JSON I simply put .json in the url, obviously the return handling is on the Controller.
My question is how to do something like Laravel. I would like, instead of creating a method to return html and another one for json, to have only one for both and in the view I could determine what would be the return.
public function lista(){
$produtos = 'select na tabela';
return view('produtos.listagem')->withProdutos($produtos);
}
The above code returns html by default, would you choose the return type?
Hugs