SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'created_by' and 'updated_by' cannot be null

huangapple go评论51阅读模式
英文:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'created_by' and 'updated_by' cannot be null

问题

我一直在尝试解决这个问题,从昨天开始。在我的更新方法中有一个问题,我无法解决它。
我一直在尝试更新services表的外键。

用户创建了一个服务,现在我想更改创建它和更新它的用户的名称,但什么都没有发生,我一次又一次地遇到这个问题。

这是我的edit.blade.php表单字段:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'created_by' and 'updated_by' cannot be null

这是我的控制器的更新方法:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'created_by' and 'updated_by' cannot be null

我尝试了许多方法,搜索了成千上万的内容,几乎看了10次,但仍然没有发生任何事情。

英文:

I have been trying to solve this issue from yesterday. There is an issue in my update method and I can't figure it out.
I have been trying to update my foreign key of the services table.

User created a service and now I want to change the name of the user that created it and that updated it but nothing is happening I am getting this issue again and again.

This is my form field of the edit.blade.php
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'created_by' and 'updated_by' cannot be null

And this is the update method of my Controller:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'created_by' and 'updated_by' cannot be null

I have tried many things, searched for thousand of things , watched for almost 10 times still nothing happened.

答案1

得分: 0

  1. 检查选项的值,确保它们实际设置而不是 value=""
  2. 在服务器端检查请求的值通过 dd($request->all())
  3. 确保你的字段存在于你模型的 $fillable 数组中
英文:

some things to do:

  1. inspect the values of your options to check if they are actually set and not value=""
  2. inspect the values of your request server side by dd($request->all())
  3. make sure your fields exist in your model's $fillable array

答案2

得分: 0

检查请求中的created_byupdated_by值是否有效或无效。

dd($request->created_by)
dd($request->updated_by)
英文:

Check if the created_by and updated_by values from request is valid or not

dd($request->created_by)
dd($request->updated_by)

huangapple
  • 本文由 发表于 2023年7月13日 13:43:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76676259.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定