I am not able to make a user login in Laravel. I am using username
instead of email
.
Below is my Routes
use App\Message;
Route::get('/', function () {
return view('welcome');
});
//
Route::post('/contact','MessageController@store');
Route::get('/admin9419/dashboard','AdminDashboardController@index')->name('dash');
Route::get('/admin9419/login','SessionsController@create')->name('home');
Route::post('/admin9419/login','SessionsController@store');
Route::post('/admin9419/logout','SessionsController@destroy');
This is my SessionController File
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class SessionsController extends Controller
{
public function __construct()
{
$this->middleware('guest');
}
public function create(){
return view('sessions.create');
}
public function destroy(){
auth()->logout();
return redirect()->home();
}
public function store(){
if(!auth()->attempt(['username'=>request('username'),'password'=>request('password')])){
return back();
}
return redirect('/admin9419/dashboard');
}
}
Error:
Type error: Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable
User class:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
//
}
Can anyone help what i missed?