Everytime getting last event ID in laravel

53 Views Asked by At

i am inserting data of which event subscribed button is clicked , for that i need event id here i am passing event id but each time i am getting last event id

i have tried this for loop and passing specific event id

   <form action="{{route('postSubscribed')}}" method="POST">
          @csrf
          <input type="text" name="search" placeholder="Search Event...">
      </div>
      
      <div class="row">
        @foreach($data as $index => $event)
        <div class="col-sm-6 col-md-4 col-lg-3">
          <div class="box">
           
              <div class="img-box">
                <img src="{{ asset('storage/' . $event->image) }}" alt="">
              </div>
              <input type="hidden" name="eventId" value="{{ $event->id }}">
              <div class="detail-box">
                <h6>
                  {{$event->eventName}}
                </h6>
                <h6>
                  Price
                  <span>
                    {{$event->price}}
                  </span>
                </h6>
              </div>
              <div class="detail-box">
                <p class="mute-text">
                    {{$event->desc}}
                  </p>
              </div>
              <div class="location-box">
                <span style="font-size: 24px;">&#x1F4CD;</span>
                <p class="location-text">
                  {{$event->location}}
                </p>
              </div>
              <div class="btn-box">
                <button name="submit" type="submit">
                 Subcribe
                </button>
              </div>
            
          </div>
        </div>
@endforeach

and in controller i am printing that

  public function postSubscribed(Request $request)
    {
        $eventId = $request->input('eventId');
        dd($eventId);
    }
0

There are 0 best solutions below