I have this problem in Laravel 5: Class 'App\Http\Controllers\Response' not found . I'm new to all of this, so I need your helpers.
I am trying to get json response from table "funcionarios". My controller :
<? php namespace App\ Http\ Controllers; use Illuminate\ Http\ Request; use App\ Http\ Requests; use App\ funcionario; class funcionarioPruebaController extends Controller { public function index() { try { $response = [ 'funcionarios' => [] ]; $statusCode = 200; $funcionario = \App\ funcionario::all() - > take(9); foreach($funcionario as $item) { $response['funcionarios'][] = [ 'id_funcionario' => $item - > id_funcionario, 'nombre' => $item - > nombre, 'apellido' => $item - > apellido, 'ci' => $item - > ci, 'rango' => $item - > rango, 'direccion' => $item - > direccion, 'telefono' => $item - > telefono ]; } } catch (Exception $e) { $statusCode = 404; } finally { return Response::json(array('error' => false, $response, $statusCode)); } }
and my route.php :
Route::group(array('prefix' => 'xxx'), function() { Route::resource('funcionarios', 'funcionarioPruebaController'); });
How can I get all the lines in json format?
source share