2014-11-28 10:56
浏览 44


I have something strange happening which I can't understand and wondered if anyone could help me work out what's going on.

I have 2 tables (assessors, processes) and a pivot (process_assessor). I am trying to update the pivot with an assessor's processes so I have a form which when submitted is passed to this method...

public function updateProcesses( $id )
    $assessor = $this->model->find( $id );
    return $assessor->processes()->sync( $this->request->get( 'process_id' ) );

This works fine however when updating a user to have no processes I get an error message...

Argument 1 passed to Illuminate\Database\Eloquent\Relations\BelongsToMany::formatSyncList() must be of the type array, null given, called

However, (and this is the weird bit) I also have a user profile module which uses exactly the same way to 'sync' with the pivot table however when I submit that form with all options for that particular module unchecked then it works, the user is detached from them in the pivot.

What am I doing wrong? Any ideas?

图片转代码服务由CSDN问答提供 功能建议

我发生了一些奇怪的事情,我无法理解,并想知道是否有人可以帮我弄清楚发生了什么。 </ p>

我有2个表(评估者,进程)和一个数据透视表(process_assessor)。 我正在尝试使用评估者的流程更新数据透视,因此我有一个表单,当提交时传递给此方法... </ p>

  public function updateProcesses($ id)
 $ assessor = $ this-&gt; model-&gt; find($ id); 
返回$ assessor-&gt; processes() - &gt; sync($ this-&gt; request-&gt; get('process_id  ')); 
 </ code> </ pre> 

这很好但是当更新用户没有进程时我收到错误消息... </ p>

 传递给Illuminate \ Database \ Eloquent \ Relations \ BelongsToMany :: formatSyncList()的参数1必须是数组类型,给定null,称为
 </ code> </ pre> 
 \  n 

然而,(这是奇怪的一点)我还有一个用户配置文件模块,它使用与数据透视表“同步”完全相同的方式但是当我提交该表单时,该特定模块的所有选项都未选中 它起作用,用户在枢轴中与它们分离。</ p>

我做错了什么? 有什么想法吗?</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题