1
I am trying to send the data of a Login form by the POST method, however it is not going at all, nothing appears error.
Just follow my code
Form
<form class="form-group">
{!! Form::open(['route' => 'user.login', 'method' => 'post']) !!}
<div class="form-group">
{!! Form::text('username',null,['class'=>'form-control form-control-user', 'id'=> 'exampleInputEmail','placeholder'=>'Usuário']) !!}
</div>
<div class="form-group">
{!! Form::password('password',['class'=>'form-control form-control-user','placeholder'=>'Senha']) !!}
</div>
<a>
{!! Form::submit('Entrar',['class'=>'btn btn-primary btn-user btn-block']) !!}
</a>
{!! Form::close() !!}
</form>
Controller
<?php
namespace App\Http\Controllers;
use App\Repositories\UserRepository;
use App\Validators\UserValidator;
class DashboardController extends Controller
{
private $repository;
private $validator;
public function __construct(UserRepository $repository, UserValidator $validator)
{
$this->repository = $repository;
$this->validator = $validator;
}
public function auth()
{
echo "Auth Method";
}
}
Routes
<?php
Route::get('/', function () {
return view('welcome');
});
// Rotas para Login do Usuário
Route::get('/login', ['uses' =>'Controller@fazerLogin']);
Route::post('/login', ['as'=>'user.login','uses' => 'DashboardController@auth']);
public function auth(Request $request)
already tried to put like this and searches the information sent$request->all()
?– novic
An error has now appeared: Declaration of App Http Controllers Dashboardcontroller::auth(Illuminate Http Request $request) should be compatible with App Http Controllers Controller::auth(App Http Controllers Request $request)
– FabianoF
You set this method in your base controller?
– gmsantos
This is the error of
namespace
in which the correct isuse Illuminate\Http\Request;
– novic
<?php namespace App Http Controllers; use Illuminate Http Request; use App Repositories Userrepository; use App Validators Uservalidator; class Dashboardcontroller extends Controller { private $Repository; private $Validator; public Function __Construct(Userrepository $Repository, Uservalidator $Validator) { $this->Repository = $Repository; $this->Validator = $Validator; } public Function auth(Request $request) { echo "Auth Method"; } }
– FabianoF
Still the mistake continues.
– FabianoF
App\Http\Controllers\DashboardController::auth(Illuminate\Http\Request $request)
renamed this method of hiscontroller
now that I’ve seen ... putauthenticate
, because in theController
already have a method with the same name @Fabianof change the routes also when change the method name– novic