2017-01-12 137 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

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