【发布时间】:2019-11-13 21:20:50
【问题描述】:
我有一个可以正常工作的 create 方法,但尝试创建它的关系却失败了:
public function create(array $article, string $note)
{
$art = $this->article->create($article);
print($art->id) // this line is for helping me to know if id is successfully generated. It works!
$this->article->note()->create([
'article_id' => $art->id, // the id desapears
'note' => $note
])
}
控制台日志:
违反完整性约束:1048 列“article_id”不能为空(SQL:插入
notes(article_id,note,updated_at,created_at)值(?,TESTING,2019-11- 13 13:03:07, 2019-11-13 13:03:07))"
【问题讨论】:
-
什么返回 dd($art);?