I have a tables peoples
countries
and a pivot table country_people
. The pivot tables has got attributes countries_id
peoples_id
number
. I am able to get the foreign keys into the pivot table but i can't insert into number. How do i do this ?
People model
public function countries()
{
return $this->belongsToMany('App\Country')->withPivot('number')
->withTimestamps();
}
Country model
public function peoples()
{
return $this->belongsToMany('App\People')->withPivot('number')
->withTimestamps();
}
Controller
$people = new People(array(
'quantity' => $request->get('quantity'),
));
$people->save();
$order->countries()->sync($request->get('id')->attach('quantity'));