I am trying to make a custom login module based on the default login (Route :: auth ()), but somehow, the messages corresponding to a 'required' validation rules appear, in both fields, email and password, the problem is that I do not know where the validation rules are being applied. This error also happens to me in the default login.
FORM
@section('contenido')
<div class="row">
<div class="col-md-12">
@if(count($errors) > 0)
<div class="alert alert-danger alert-dismissible fade in" role=alert >
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<ul>
@foreach($errors->all() as $errores)
<li style="font-weight: bolder; list-style-type: none">{{$errores}}</li>
@endforeach
</ul>
</div>
@endif
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
@if(count($errors) > 0)
<div class="alert alert-danger alert-dismissible fade in" role=alert >
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<ul>
@foreach($errors->all() as $errores)
<li style="font-weight: bolder; list-style-type: none">{{$errores}}</li>
@endforeach
</ul>
</div>
@endif
</div>
</div>
</div>
<div id="superespacio"></div>
<div class="container">
<div class="row">
{{Form::open(array('url' => 'login', 'method'=>'POST','class'=>"form-horizontal"))}}
<div class="form-group">
{!! Form::label('Correo Electronico', null, array('class' => 'col-sm-2 control-label')) !!}
<div class="col-sm-10">
{!! Form::text('correo', null, array('class' => 'form-control','placeholder' =>'Introduce tu Correo Electronico')) !!}
</div>
</div>
<div class="form-group">
{!! Form::label('Contraseña', null, array('class' => 'col-sm-2 control-label')) !!}
<div class="col-sm-10">
{!! Form::text('pass', null, array('class' => 'form-control','placeholder' =>'Introduce tu Contraseña')) !!}
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
{!! Form::submit('Inicia Session', ['class'=>'btn btn-default']) !!}
</div>
</div>
{{ Form::close() }}
</div>
</div>
<div id="superespacio"></div>
@endsection
MODULE AUTHCONTROLLER (THE ONE THAT COMES BY DEFAULT)
<
?php
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/';
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
//'name' => 'required|max:255',
// 'correo' => 'required|unique:users',
// 'pass' => 'required|min:6',
//|email|max:255
//|confirmed
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
// 'name' => $data['name'],
'email' => $data['correo'],
'password' => bcrypt($data['pass']),
]);
}
}
As you can see in this module, I have deactivated all the validation rules, because even so, I try to validate the email and password.
In the AuthenticatesUsers trait I tried to comment on this line to see if that was why, same result
protected function validateLogin(Request $request)
{
$this->validate($request, [
//$this->loginUsername() => 'required', 'password' => 'required',
]);
}
The route
Route::auth();
Route::group(['middleware'=>'auth'], function() {
Route::resource('usuarios', 'UsuariosController');
});
The route works well, by giving the user link it sends you to the middleware, but as I say I do not go from login to home, in the validation screen, even filling in the fields, it puts the message of 'required'
/ *********************** AFTER EDITION ************** ****** USER MODEL
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $table = 'users';
protected $fillable = [
'name', 'email', 'password','tipo',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function articulos($value='')
{
return $this->hasMany('App\modelos\articulo');
}
}