Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel authentication throwing weird error

Illuminate \ Database \ QueryException
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user.deleted_at'
in 'where clause' (SQL: select * from `user` where `user`.`deleted_at` is
null and `username` = john limit 1)

So I am sending the following data to my login route: username=john&password=test

But when I execute the following code in my routes.php I get the error show above.

Route::post('login', function()
{
    $credentials = array(
        "username" => Input::get("username"),
        "password" => Input::get("password")
    );

    if (Auth::attempt($credentials))
    {
        return Redirect::intended('dashboard');
    }
    else {
        return Redirect::to('login');
    }

});

The thing that bothers me is that I don't have deleted_at column in my user table and I don't know why laravel need to this column in my table when all I am doing is trying to login.

like image 547
timewarper Avatar asked Dec 21 '25 13:12

timewarper


1 Answers

The thing that bothers me is that I don't have deleted_at column in my user table

Yes, the error message is complaining about that.

I don't know why laravel need to this column in my table when all I am doing is trying to login.

Your User model likely has soft deletion enabled. Look for $softDelete in your User.php file in the app/models folder and set it to false, or add the column if you want soft deletions.

like image 147
ceejayoz Avatar answered Dec 24 '25 02:12

ceejayoz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!