我有一个BlogImage模型和一个Blog模型。现在我想知道将create方法与关系一起使用是否正确,以及为什么像下面这样使用它:$blogImage = new BlogImage();$blogImage->blog()->create([ //this is making the blog for me 'title' => $request->title, 'content' => $detail, 'category_id' => $request->category_id, 'author' => Auth::user()->id, 'meta_description' => $request->title, 'meta_image' => $meta_image,]);另外,我想知道这种方法和正常形式有什么区别,即:Blog::create([ 'title' => $request->title, 'content' => $detail, 'category_id' => $request->category_id, 'author' => Auth::user()->id, 'meta_description' => $request->title, 'meta_image' => $meta_image,]);
1 回答
幕布斯7119047
TA贡献1794条经验 获得超8个赞
- 1 回答
- 0 关注
- 161 浏览
添加回答
举报
0/150
提交
取消