添加外键对象serverfireteam/panel的选择

Tho*_*ing 5 php mysql laravel-5

我正在使用Serverfireteam LaravelPanel(使用zofe/rapyd-laravel).我为一个实体创建了一个crud控制器.此实体具有另一个表的外键.现在我想显示这个外键的自动完成,但它只显示一个空的选择框.

我的Controller代码如下所示:

 public function  edit($entity){

    parent::edit($entity);
    $this->edit = \DataEdit::source(new \App\Regal());
    $this->edit->add('bezeichnung', 'Bezeichnung','text');
    $this->edit->add('nummer', 'Nummer','text');
    $this->edit->add('maxPaletten', 'Max Paletten je Ebene','text');
    $this->edit->add('anzahlEbenen', 'Anzahl Ebenen','text');

    $this->edit->add('kunde_id','Kunde','select')->options(\App\Kunde::lists("name", "id"));


    return \View::make('regale.editPanel', array(
        'title'          => $this->entity ,
         'edit' => $this->edit
        )); 


}    
Run Code Online (Sandbox Code Playgroud)

我的模型文件:

class Kunde extends Model {

protected $table = 'kunden';
public function listPaletten(){
    return $this->hasMany('App\Models\Palette');
}
public function listAdressen(){
    return $this->hasMany('App\Models\Adresse');
}
public function listRegale(){
    return $this->hasMany('App\Models\Regal');
}
public function listArtikel(){
    return $this->hasMany('App\Models\Artikel');
}
}
Run Code Online (Sandbox Code Playgroud)

..

class Regal extends Model {

protected $table = 'regale';

public function kunde(){
    return $this->belongsTo('App\Models\Kunde');        
}
}
Run Code Online (Sandbox Code Playgroud)

Ali*_*ebi 1

您正在使用 options 方法, options 方法用于 selectbox 。

正如文件中所解释的:

自动完成(使用 twitter typeahead 具有自动完成功能的输入字段和使用 relation.fieldname 和 search() 方法的 ajax 功能)

$this->edit->add('author.fullname', 'Author', 'autocomplete')->search(array('firstname', 'lastname'));
Run Code Online (Sandbox Code Playgroud)