POST form button does not work on Laravel 6

Asked

Viewed 251 times

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']);
  • 1

    public function auth(Request $request) already tried to put like this and searches the information sent $request->all()?

  • 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)

  • You set this method in your base controller?

  • This is the error of namespace in which the correct is use Illuminate\Http\Request;

  • <?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"; } }

  • Still the mistake continues.

  • App\Http\Controllers\DashboardController::auth(Illuminate\Http\Request $request) renamed this method of his controller now that I’ve seen ... put authenticate, because in the Controller already have a method with the same name @Fabianof change the routes also when change the method name

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.