2 months ago

sync many to many

Posted 2 months ago by Aronaman

hello guys

room parent has 5 room child. quantity count the room child show in front end. my question is if the customer choice quantity b/n 1 to 5 . let say the customer choice 3 and book the room. the first 3 room children save in pavot table of booking_Individual. how can i do this??

room(parent)->individualRoom(child) 1 to many relationship


<div class="form-group">

              <select  name="quantity" >   
                  @for($i=1; $i<=$result; $i++)  
                  <option  >{{$i}}</option>


booking.php //model

    public function individualRooms()

      return $this->belongsToMany(individualRoom::class,'booking__individualroom');


$booking =$room->bookings()->create($booking);

if the user select 2 quantity the store the first 2 individual room, if 3 quantity selected same the first 3 from the individualroom .....

Please sign in or create an account to participate in this conversation.