0
我有一個語音模型,可以保存所有新語音,每個語音都有名稱和語言字段。我的第二個模型是設備模型,我想在設備窗體視圖中將這些聲音填充爲複選框,並讓用戶選擇一個或多個聲音並將其保存到相關的設備中作爲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');
}
機器人佛RM
<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>
感謝您的回覆@Thomas我解決了它:) –
然後請將此答案標記爲解決方案 –
我可以問你一個問題嗎?現在,當我創建新設備並檢查多個複選框時,我將存儲新的設備信息,但同時我想將** Device_id **和** Voice_id **保存到數據透視表中? –