我有一个下拉列表,下拉列表的值在另一个表上。。我把它取下来,所以这里我得到的是1来显示,而不是样本客户机3的值,下拉列表有。。帮帮忙谢谢。
看这里我的下拉列表和它的值
请看我的下拉列表,当我选择sample client时,它将插入0而不是实际的字符串为什么?请看一下我的代码谢谢
我的下拉输入
{{Form::select('clients', $clients ,null,['class' => 'form-control', 'placeholder' => 'Select Movie Provider...'])}}
我的控制器
这里是create函数
$clients = Client::all()->pluck('client_name');
return view('admin.movies.create', compact('clients'));
在视图索引上,这里是foreach循环
<td>{{$movie->movie_provider}}</td>
以及我的数据库模型关系
在客户端
class Client extends Model
{
use SoftDeletes;
protected $dates = ['deleted_at'];
// Table Name
protected $table = 'clients';
// Primary Key
public $primaryKey = 'id';
// Timestamps
public $timestamps = true;
在电影方面
public function movies(){
return $this->hasMany('App\Movie');
}
}
class Movie extends Model
{
// Table Name
protected $table = 'movies';
// Primary Key
public $primaryKey = 'id';
// Timestamps
public $timestamps = true;
public function clients(){
return $this->belongsTo('App\Client');
}
}
1条答案
按热度按时间kcrjzv8t1#
可能需要明确说明值和标签。使采集的数据如下所示:
通过做
文档:https://laravelcollective.com/docs/master/html#drop-下拉列表