我一直在laravel的一个学校项目上工作,我想能够更新我的数据库中的现有记录,我为它做了一个功能,但是当我点击更新按钮时我的数据库中的Updated_at字段被更新,没有别的,即使我改变编辑表单上的每个属性,我也观看并遵循了Laracasts laravel基础系列,但它给了我相同的结果。Laravel 5.2更新函数
这是我的存储和编辑方法我已经为它
public function update(Request $request, $id)
{
//$product = Product::findOrFail($id) = finding the Id of the Product i want to update
$product = Product::FindorFail($id);
// Requesting a update query on the attributes: name , buy price, sell price, and the foreign_key
$product->update($request->only(['naam', 'inkoopPrijs', 'verkoopPrijs', 'Fabrieken_Id']));
return redirect(Route('producten.index'));
}
提出这是模型IM uing它。
class Product extends Model
{
protected $fillable = ['Id', 'naam', 'inkoopPrijs', 'verkoopPrijs', 'Fabrieken_Id', 'updated_at', 'created_at'];
protected $table = "producten";
public function fabriek()
{
return $this->BelongsTo('App\Fabriek', 'Fabrieken_Id');
}
当我var_dump($产品)喜欢它在上面说只有Updated_at字段更新和没有别的。
如果我需要更多的信息,只是让我知道,我会添加到这个问题