在我的web应用程序中,人们可以创建帖子。除了这些帖子,他们可能会上传多张图片。为此,我有一个posts表和一个image表。发布hasMany图像,而图像属于发布。因此,images表有一个image_path列和一个post_id列。我的麻烦是弄到post_id。因为我不能在上传帖子之前获得帖子ID,所以我不能设置图片属于哪个帖子。无论如何,下面是一些代码:
public function create(){
$post = new Post;
$post->title=Input::get('title');
$post->body
我有一个包含以下字段(id、name、state_id、city_id、category_id、subcategory_id)的Post表和一个包含以下字段(id、photo_url、post_id)的PostPhoto表 Post模型有 public function user(){
return $this->belongsTo(User::class);
}
public function category(){
return $this->belongsTo(Category::class);
}
publi
我正在制作一个产品图片上传表单,结果是许多图片属于一个产品id。我该怎么做? 多张图片上传成功,但产品id仍是独立的。 这是我的控制器: public function store(ProductRequest $request,$id) {
if ($request->hasFile('photo')){
$photos = $request->file('photo');
foreach ($photos as $photo) {
$data= $request->al
我下载了所有的公共网页。例如,“Google在facebook上的页面”中最近的一篇文章如下所示:
{
"created_time": "2016-02-04T02:55:11+0000",
"message": "We hope you\u2019re just as excited about the Year of the Monkey as we are! So excited, we\u2019ve been hunting around Street View for monkey sight
像这样的代码(上传图片时执行):
gallery = Gallery.objects.get(id=album_id)
index = gallery.photo_num +1 #index will be used in later
gallery.photo_num = index
gallery.save()
1张图片上传效果很好,但如果同时上传多张图片,使用多张上传jQuery plugin.the "gallery.photo_num“会比较混乱
如何修改代码以避免此问题