它说
Illuminate \ Database \ QueryException与消息一起抛出 “ SQLSTATE [42S22]:找不到列:1054'where中的未知列'id' 子句”(SQL:从
seller
中选择*,其中id
= 1个限制1)
我使用了laravel 5.4
我在Controller类中使用此代码连接到数据库
$dataSeller = seller::where('username_seller', $kiriman->username)->where('password_seller',$kiriman->password)->get();
// $dataSeller = seller::find($id);
// $dataSeller->username = $kiriman['username_seller'];
// $dataSeller->password = $kiriman['password_seller'];
// $dataAdmin = admin::find($id);
// $dataAdmin->username = $kiriman['username_admin'];
// $dataAdmin->password = $kiriman['password_admin'];
//Function login admin
$dataAdmin = admin::where('username_admin', $kiriman->username)->where('password_admin',$kiriman->password)->get();
if (count($dataSeller)>0) {
//Login berhasil seller
Auth::guard('seller')->LoginUsingId($dataSeller[0]['id_seller']);
return redirect('/seller_login');
} elseif (count($dataAdmin)>0) {
//Login berhasil admin
Auth::guard('admin')->LoginUsingId($dataAdmin[0]['id_admin']);
return redirect('/admin_login');
} else {
//Login gagal
return "failed";
return redirect('/masuk');
}
答案 0 :(得分:0)
该错误告诉您laravel在表“ seller”中找不到列“ id”,因此您必须确认该列是否存在。
转到您的数据库,并检查“ id”列是否存在。
如果要对primary_key使用其他名称,例如IE'id_seller',则需要告诉laravel查找该名称,而不是添加
protected $primaryKey = 'id_seller';
针对您的卖方模型。还要查看laravel约定Here
的文档