2017-01-12 86 views
1

当我尝试更新db中的记录时,它不更新,并且它 returns falseLaravel 5更新记录返回false

我不能图像索引了解为图像位置传递

$product->images()->update(); 

我不能使用ids作为搜索条件,我必须update

<?php 
if (isset($product->images[$key])) { 
    $result = $product->images[$key]->update([ 
     'name' => $filename 
    ]); 
    dd($result); 
} else { 
    $product->images()->create([ 
     'name' => $filename 
    ]); 
} 
?> 

回答

1

也许你没有定义name领域作为你的图像质量模式在$fillable分配。转到您的图像模型和定义此属性:

protected $fillable = ['name']; 

文档:https://laravel.com/docs/5.3/eloquent#mass-assignment

+0

你瞎了???我在帖子中说,我不能使用ID –

+0

请检查我的更新回答 – aceraven777

+0

其他块的作品,但如果块不 –