Hello everyone, I'm starting with laravel, I've come across a problem. I created the controller, the routes, but still, it is giving me the following error:
Class App \ Http \ Controllers \ Contact 2Controller does not exist.
What should I do? I already searched the net, but to no avail. Thanks in advance.
For a better understanding, here's the code.
Controller:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class Contato2Controller.php extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('welcome');
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function enviar(Request $request)
{
$contato = new Contato();
$contato->nome = $request->get('nome');
$contato->email = $request->get('email');
$contato->mensagem = $request->get('mensagem');
$contato->save();
echo "Dados armazenados com sucesso! Código: " .$contato->id;
}
public function lista()
{
return view('lista', array('contatos'=>Contatos::all()));
}
}
Routes:
Route::get('/','Contato2Controller@index');
Route::post('/enviar','Contato2Controller@enviar');
Route::get('/lista','Contato2Controller@lista');
OBS: I'm using version 5.1 of laravel.