2017-11-18 111 views
0

我是新手laravel我正在使用updateorcreate模型。但是这显示错误MassAssignmentException end_time在模型任务时间我正在使用protected $ guarded = array();这是我在做什么。MassAssignmentException in updateorcreate in laravel 5.4

$endtask= Tasktimelog::updateOrCreate(
     [ 
      'task_id' => $taskid, 
      'action_type'=>4, 
      'user_id'=> auth()->id() 
     ], 
     [ 
      'end_time'    => $endtimeis, 
      'total_time'   => request('totalseconds'), 
      'remark'    => request('remark'), 
      'actual_complete_time' => $diff, 
      'project_id'   => $getprojectid->project_id 
     ]); 
+0

如果你使用'$保护守卫= [];'(你应该分享你是如何这样做),请确保你不” t也有'$ fillable'集合。 – apokryfos

+0

请建议我该怎么做,如果我犯了错误,我是新来的laravel指导我。谢谢你 – vinod

+0

分享你的型号代码 – apokryfos

回答

0

尝试,并适用于所有领域

protected $fillable = [ 
     'end_time'    => $endtimeis, 
     'total_time'   => request('totalseconds'), 
     'remark'    => request('remark'), 
     'actual_complete_time' => $diff, 
     'project_id'   => $getprojectid->project_id 
    ]; 
+0

没有它没有工作。我用你建议在模型** Tasktimelog **并删除**保护$守卫= []; **表单模型,但仍然问题是一样的。请告诉我,如果我犯了错误。 – vinod