Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Aronaman's avatar

fetching Wrong Data

web.php

//self reservation
Route::post('/selfBook/{room}', 'SelfBookController@store')->name('selfBook.store');
Route::get('/selfBook/{room}', 'SelfBookController@create')->name('selfBook.create');// i pass room in create method b/c i use values of room while create new booking

blade file

 @if ($room->quantity > 0)
                <form action="{{ route('selfBook.create', $room) }}" method="GET">
                    {{ csrf_field() }}
                    <button type="submit" class="button button-plain">Pay Later <br> <span>Valid Only for 20 Min</span></button>
                </form>
            @endif

selfBook Controller

 public function create(Room $room)
    {
       dd($room);
....
}

my problem is fetching the last data in all children! when i click to single room type it shows me, master, if i click on the double it shows me, master. fetching only the master(last children).

0 likes
7 replies
Snapey's avatar

Not sure I understand the question. The last reply should call your create function giving it Room model 5

Does it hit your DD with room 5 ?

Aronaman's avatar

yes dd() it gives me always room5 ? the request always room5 inside the "A Hotel" the problem is in every hotel click the room give me the last hotel for all. here is extra code

parent Blade

  <div class="action">
              <a href="{{route('singleRoom.show', [$room->slug, $room->id])}}" class="btn btn-info">View Detail</a>
           
               <button type="button" class="btn btn-default" style="background-color:#ff9f1a; color: black" data-toggle="modal" data-target="#reserveForm">
                   Book Now<br> <span style="color: green; font-weight: bold;">5%-10% Off</span>
              </button>
          
            

            </div>



      <!-- Modal Confrence-->
<div class="modal fade" id="reserveForm" tabindex="-1" role="dialog" aria-labelledby="reservationForm" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="reservationForm">Get Rest Booking Service</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">

      
       @include('SelfBook.general')



</div>
</div>
</div>
</div>

selfBook.general blade

 @if ($room->quantity > 0)
                <form action="{{ route('selfBook.store', $room) }}" method="POST">
                    {{ csrf_field() }}
                    <button type="submit" class="button button-plain">Pay Later <br> <span>Valid Only for 20 Min</span></button>
                </form>
            @endif

web

Route::get('/room/{slug}/{id}', 'SingleRoomController@show')->name('singleRoom.show');
Route::get('/conference/{slug}/{id}', 'SingleConferenceController@show')->name('singleConference.show');

//self Room
Route::get('/selfBook', 'SelfBookController@index')->name('selfBook.index');
Route::post('/selfBook/{room}', 'SelfBookController@store')->name('selfBook.store');
Route::patch('/selfBook/{room}', 'SelfBookController@update')->name('selfBook.update');
Route::delete('/selfBook/{room}', 'SelfBookController@destroy')->name('selfBook.destroy');
 public function store( Room $room)
    {
        dd($room);

         if(Auth::check())
        {
              $roomPrice=$room->room_price;
       $check_in=CarbonImmutable::now();
       $check_out=$check_in->add(1, 'day');
       $user_id=Auth::user()->id;
.
.
...
}

any help:)

Snapey's avatar

Well thats a completely different issue. So your problem is that the modal is not dynamic?

You need to pass the clicked room through to the modal and not try to hard code it into the modal

Please or to participate in this conversation.