Good afternoon, I'm using Laravel 5 to redo a system and on login screen when authentication is not done the user is redirected to the form again but I can not return any errors.
Model User
protected $connection = 'pgsql2';
protected $primaryKey = 'cod_funcionario';
public $timestamps = false;
protected $table = 'funcionarios';
protected $fillable = ['login', 'senha'];
protected $hidden = ['senha', 'remember_token'];
public function getAuthPassword()
{
return $this->senha;
}
public function setSenhaAttribute($value)
{
$this->attributes['senha'] = bcrypt($value);
}
AuthController.php
protected $redirectPath = '/admin';
protected $loginPath = '/admin/auth/login';
public function __construct()
{
$this->middleware('guest', ['except' => 'getLogout']);
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
]);
}
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => $data['password'],
//'password' => bcrypt($data['password']),
]);
}
public function postAdminLogin()
{
if (Auth::attempt(['login' => Request::input('login'), 'password' => Request::input('senha')]))
{
return redirect()->intended('admin');
}
else{
return Redirect::to('admin/auth/login');
}
and in the view I'm trying to display the errors as follows:
@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{!! $error !!}</li>
@endforeach
</ul>
</div>
@endif