1
votes

I am new in laravel, for user login and registration I have created my own table named as 'provider_regs' which contains auto_id as a primary key (provider_regs table doesn't contain any key named as 'id'). After successful registration when I try to hit the same registration url in another tab then I am getting the following error page:

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

and when I do clear history then it won't show me that error page. I don't know what to do, Please give any suggestion.

1
can you paste your laravel query here?Vijay Sankhat
I got these queries on the error page, at Connection->runQueryCallback('select * from provider_regs where provider_regs.id = ? limit 1', array('0'), object(Closure)) in Connection.php line 596 at Connection->run('select * from provider_regs where provider_regs.id = ? limit 1', array('0'), object(Closure)) in Connection.php line 315 at Connection->select('select * from provider_regs where provider_regs.id = ? limit 1', array('0'), true) in Builder.php line 1389AmarjaPatil4

1 Answers

1
votes

In your ProviderRegs model you may change the primary key, because the default is id, and you would like to use auto_id.

Add $primaryKey variable to your model (App\ProviderRegs.php):

class ProviderRegs extends Model {
    protected $primaryKey = 'auto_id';
}

Eloquent will also assume that each table has a primary key column named id. You may define a $primaryKey property to override this convention.