I'm developing a project in Laravel, but I'm having a hard time understanding how login and user authentication works to redirect to the dashboard.
I have a table in the database named "user", which contains the following columns: id, name, user, password and email.
Authentication has to be done through the email and password, which are already registered. The password is MD5 hash, being created through PhpMyAdmin.
The AdminController was created. Follow below:
public function index(Request $request){
$credentials = $request->only('email', 'senha');
if (Auth::attempt($credentials)) {
// Authentication passed...
return redirect()->intended('dashboard');
} else {
return redirect()->intended('index');
}
}
Model Admin was also created. Follow below:
class Admin extends Model
{
protected $fillable = ['nome', 'usuario', 'senha', 'email', 'admin'];
protected $guarded = ['id','created_at', 'update_at'];
protected $table = 'usuario';
public $timestamps = false;
}
However, when I type the user and password of the Login screen, the following error occurs:
Method App \ Http \ Controllers \ DashboardController :: store does not exist.
My Login view looks like this:
<div class="account-pages mt-5 mb-5">
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-5">
<div class="card">
<!-- Logo -->
<div class="card-header pt-4 pb-4 text-center bg-primary">
<a href="index.html">
<span><img src="site/img/logo-login.png" alt=""></span>
</a>
</div>
<div class="card-body p-4">
<form action="{{ url('dashboard') }}" method="POST">
{{ csrf_field() }}
<div class="form-group">
<label for="emailaddress">E-mail</label>
<input class="form-control" type="email" id="emailaddress" name="email" placeholder="Digite seu e-mail" autofocus>
</div>
<div class="form-group">
<a href="pages-recoverpw.html" class="text-muted float-right"><small>Esqueceu sua senha?</small></a>
<label for="password">Senha</label>
<input class="form-control" type="password" name="senha" id="password" placeholder="Digite sua senha">
</div>
<div class="form-group mb-3">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="checkbox-signin" checked>
<label class="custom-control-label" for="checkbox-signin">Lembrar- me</label>
</div>
</div>
<div class="form-group mb-0 text-center">
<button class="btn btn-primary" type="submit"> Entrar </button>
</div>
</form>
</div> <!-- end card-body -->
</div>
<!-- end card -->
</div> <!-- end col -->
</div>
<!-- end row -->
</div>
<!-- end container -->
</div>
<!-- end page -->
@endsection
What are the next steps I should take? Can anyone help me with this?