I'm trying to authenticate a user from the table called "cients_table"
Migration
public function up()
{
Schema::create('clients_table', function (Blueprint $table) {
$table->increments('id');
$table->string('fullname');
$table->string('email')->unique();
$table->string('username')->unique();
$table->string('password');
$table->text('address');
$table->string('phone_number');
$table->string('location');
$table->string('gender');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('clients_table');
}
And i read that to specify the table your model should work with you should and it the $table to it. So in my Client model this is what's there
namespace App;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
class ClientModel extends Model implements Authenticatable
{
use \Illuminate\Auth\Authenticatable;
public $table = 'Clients_table';
}
In my controller. This is what i'm trying to authenticate the user with
public function client_login(Request $request){
if (Auth::attempt(['email' => $request['email'], 'username' => $request['username']])){
return redirect()->route('client_dashboard');
}
return redirect()->back();
}
but it's giving me this error
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'username' in 'where
clause' (SQL: select * from `users` where `email` = chinonsoeke@gmail.com
and `username` = king_eke limit 1)
apparently it's not using the right table to fetch the info from.. Please what can I do ??