Laravel Form::model的选定值标记不';t从模型绑定属性

Laravel Form::model的选定值标记不';t从模型绑定属性,laravel,laravel-5,Laravel,Laravel 5,我正在学习Laravel,在尝试将模型的属性绑定到select标记的选定值时遇到了一个问题。我试图将第三个参数保留为null,因为我相信表单模型绑定会自动处理它,但它不起作用。以下是我已经尝试过的: {{$article->tag_list}} // show [1,3] //it doesn't work {!! Form::select('tag_list[]', $tags, null , ['class' => 'form-control', 'mul

我正在学习Laravel,在尝试将模型的属性绑定到select标记的选定值时遇到了一个问题。我试图将第三个参数保留为null,因为我相信表单模型绑定会自动处理它,但它不起作用。以下是我已经尝试过的:

   {{$article->tag_list}} // show [1,3]

    //it doesn't work 
   {!! Form::select('tag_list[]', $tags, null , ['class' => 'form-control', 'multiple'] ) !!}
    -------------

    //it doesn't work as well
    {!! Form::select('tag_list[]', $tags, $article->tag_list  , ['class' => 'form-control', 'multiple'] ) !!}
    -----------

    //it works
    {!! Form::select('tag_list[]', $tags, [1,3] , ['class' => 'form-control', 'multiple'] ) !!}
在这个模型中,我使用了运行良好的
getTagListAttribute()

public function getTagListAttribute(){
    return $this->tags->lists('id');
}

通过文本输入,表单工作正常。顺便说一句,我使用的是5.2.1版本。我在这里遗漏了什么?

我找到了丢失的那块。
select
函数需要一个数组,但
getTagListAttribute()
返回一个集合对象

public function getTagListAttribute(){
  return $this->tags->lists('id')->all();
}
or I can do this
public function getTagListAttribute(){
  return $this->tags->lists('id')->toArray();
}

如果您在5.1中,
$this->tags->lists('id')
已更改为
$this->tags->lists('id')->all()
。谢谢。这是一个救命恩人。需要有人更新laravel 5.3函数列表()中laracast视频上的此信息。函数列表()已更改为Pulk()