【发布时间】:2017-07-15 20:15:38
【问题描述】:
我有一个语音模型,我可以在其中保存所有新语音,并且每个语音都有名称和语言字段。我的第二个模型是设备模型,我想在设备表单视图中将这些声音填充为复选框,并让用户选择一个或多个并将其作为 JSON 保存到相关设备。
有人 - 帮助! :)
我想如何将声音保存到机器人
{
"voice_name":"sample1",
"voice_language":"English"
}
语音模型
public $fillable = [
'name',
'language'
];
public function devices()
{
return $this->belongsToMany('App\Models\Device');
}
设备型号
public $fillable = [
'device_name',
'version',
'voices'
];
public function voices()
{
return $this->hasMany('App\Models\Voice');
}
机器人形态
<div class="form-group">
{!! Form::label('device_name', 'Device Name:') !!}
{!! Form::text('device_name', null, ['class' => 'form-control') !!}
{!! Form::label('version', 'version:') !!}
{!! Form::text('version', null, ['class' => 'form-control') !!}
<div class="form-group">
{!! Form::label('voices', 'Voices:') !!}
//I want to list all the voices here as Checkboxes
{!! Form::checkbox('voices[]', null, ['class' => 'form-control']) !!}
</div>
【问题讨论】:
标签: php json laravel eloquent blade