3

I have the routes

Route::get('/login', 'LoginController@index');
Route::post('/login', 'LoginController@login');

the get to display my my login screen and the post for submission.

This is my controller login

 public function index(){
       return view('Login.index');
 }

 public function login(Request $request)
 {

 }

How can I get my form to send requests to this controller via the route? I'm trying this way

{!! Form::open(['id'=>'Formulario','route' => ['login.login'],'class'=>'form']) !!}

but the following error occurs

Route [login.login] not defined.

Bruno
  • 173
  • 3
  • 8

1 Answers1

3

Name the route to make it work:

Route::post('/login', 'LoginController@login')->name('login.login');

Or:

Route::post('/login', ['as' => 'login.login', 'uses' => 'LoginController@login']);
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279
  • this worked perfectly, when I use Route :: resource ('/ client', clientcontroller); and do the client.store route it works without me needing to put the name, is it because of the resource? – Bruno Feb 15 '18 at 14:35
  • 1
    @Bruno yes, `::resource()` registers route names for you. Run `php artisan route:list` command to see all registered routes with their names. – Alexey Mezenin Feb 15 '18 at 14:36