我是而不是使用Eloquent。Laravel5 - 使用數據庫驅動程序更改主鍵列的名稱
我的用戶表使用userid
作爲主列名(不id
),我有UserItem實現可認證接口和我的配置/ auth.php看起來是這樣的:當我重新命名
'providers' => [
'users' => [
'driver' => 'database',
'table' => 'user',
],
],
一切正常以「ID」列,但如果不這樣做,我得到這個錯誤:因爲這個代碼在我看來
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select * from `user` where `id` = 55 limit 1)...
(它的默認,只檢查是否顯示登錄/註冊或登錄用戶菜單):
<?php if(auth()->guard()->guest()): ?>
它的這個指令:
@guest
我在哪裏可以改變它,所以它不會查找id
而是userid
呢?
只要改變列ID(它應該是反正):/或重新實現['GenericUser'](HTTPS:// github上。com/laravel/framework/blob/bd352a0d2ca93775fce8ef02365b03fc4fb8cbb0/src/Illuminate/Auth/GenericUser.php#L32) –