Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

KonScyence's avatar

Change SQL query of laravel Auth with ID

Hello, I would like to use this:

Auth::loginUsingId($user['uid'], true);

The problem is that in the database, the column of the id is not id, but uid. How do I have to change the SQL query?

Error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select * fromtkl_userswhereid= 1 limit 1)

Thanks

0 likes
2 replies
bobbybouwmann's avatar
Level 88

I think you need to update your User model on trhee places

class User 
{
    protected $casts = [
        'uid' => 'string'
    ];

    protected $primaryKey = "uid";

    public $incrementing = false;
}

I believe this should do the job!

1 like

Please or to participate in this conversation.