I've this issue in Laravel 5: Class 'App\Http\Controllers\Response' not found
. I'm new in all this, so I need your help folks.
I'm trying to get a json response from my table 'funcionarios'. My Controller is:
<? 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 is:
Route::group(array('prefix' => 'xxx'), function() {
Route::resource('funcionarios', 'funcionarioPruebaController');
});
How can I get all the rows in a json format?
\Response::json();
Thank you Tim Lewis! You're awesome! :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With