I have a Voice Model where I save all the new voices and each voice has name and language field. My Second Model is Device Model, I want to populate these voices on the Device form view as Checkboxes and let the user to pick one or more than one and save it to related Device as JSON.
Someone - help! :)
How I want to save the voices to the Robot
{
"voice_name":"sample1",
"voice_language":"English"
}
Voice Model
public $fillable = [
'name',
'language'
];
public function devices()
{
return $this->belongsToMany('App\Models\Device');
}
Device Model
public $fillable = [
'device_name',
'version',
'voices'
];
public function voices()
{
return $this->hasMany('App\Models\Voice');
}
Robot Form
<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>