在表格中,信息字段是一个数组,当我尝试编辑这个数组中的信息时,出现这个错误:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'nationalCode' in 'where clause' (SQL: select * from `kycs` where ((`nationalCode` = 1234567891 and `state` = tehran and `city` = tehran and `address` = example address and `zipcode` = 9477143812)) limit 1)
这是我的代码:
if ($kyc = auth()->user()->kyc()->where('user_id', Auth::User()->id)->first()) {
// $data = Kyc::where('user_id', Auth::user()->id)->first();
if ($kyc->selfie['status'] == 'rejected') {
$this->validate(
[
'nationalCode' => 'required|nationalcode',
'state' => 'required',
'city' => 'required',
'address' => 'required',
'zipcode' => 'required|zipcode',
'selfie' => 'required|mimes:jpg,jpeg,png|max:2024',
]
);
$selfie_url = $this->selfie->store('documents/'.Crypt::decryptString($kyc->secret));
Kyc::updateOrCreate([
[
'information' => [
'nationalCode' => $this->nationalCode,
'state' => $this->state,
'city' => $this->city,
'address' => $this->address,
'zipcode' => $this->zipcode,
],
'selfie' => [
'url' => Crypt::encryptString($selfie_url),
'status' => 'pending',
'last_update' => Carbon::now(),
'desc' => '',
],
],
]);
return redirect()->route('frontend.auth.verification.notice');
}
什么问题
答案 0 :(得分:0)
请检查表迁移中是否有nationalCode列并运行。能否分享表的迁移。
答案 1 :(得分:0)
将您的列添加为模型中存在的日志:
protected $fillable = ['nationalCode'];
答案 2 :(得分:0)
您似乎没有正确标记要强制转换为数组的信息和自拍列。请检查您的 Kyc 模型中是否有类似的代码:
protected $casts = [
'information' => 'array',
'selfie' => 'array'
];