Good afternoon!
I created an application in Laravel where I need to save the data of a certain product, it has a one-to-one relationship. I would like to know how best to do this. I am trying the way below but it is not working, it creates the records of the photos and position but does not pass those captured in $ request.
View:
<input type='text' name='photos[0][url]'>
<input type='text' placeholder='Posição de exibição' name='photos[0][position]'>
<br>
<input type='text' name='photos[1][url]'>
<input type='text' placeholder='Posição de exibição' name='photos[1][position]'>
Controller:
$product = Product::create($request->all());
$photos = $request->get('photos');
$product->photos()->createMany($photos);
Model:
public function photos() {
return $this->hasMany('Grafica\Model\ProductPhoto');
}