2016-06-30 43 views
0

爲什麼編輯過程失敗,如何在下拉菜單中顯示數據?爲什麼錯誤,調用未定義的方法Illuminate Database Query Builder :: list()

控制器:

public function edit($id) 
{ 
    $data['data_article'] = Article::find($id); 
    $data['tambah_author'] = \DB::table('authors')->list('username','id'); 
    $data['id_author'] = \DB::table('authors')->list('id'); 
    return View::make('article.edit',$data)->with('authors',$data); 
} 

觀點:

{{ Form::select('author', 
       (['0' => 'Pilih Author'] + $tambah_author), 
       $id_author, 
       ['class'=>'form-control']) }} 

感謝,您的幫助

回答

0

Query Builder API,您需要更改listlists

$data['tambah_author'] = \DB::table('authors')->lists('username','id'); $data['id_author'] = \DB::table('authors')->lists('id');

0

正確的方法是lists

所以更改爲:

$data['tambah_author'] = \DB::table('authors')->lists('username','id'); 
$data['id_author'] = \DB::table('authors')->lists('id'); 
相關問題