控制器
public function AddPost(Request $request)
{
Post::create($request->all());
// PostImage::create();
return Redirect::to('Post');
}
我也添加了关系
class Post extends Model
{
protected $table = 'posts';
public function images()
{
return $this->hasMany('App\PostImage');
}
}
PostImage
模型
class PostImage extends Model
{
public function post()
{
return $this->belongsTo('App\Post');
}
}
我有一个表单,我添加帖子标题,发布内容和选择多个图像。我的问题是如何在post_images表中存储多个图像和post id?