mardi 14 janvier 2020

Laravel 5.4 orWhereBetween query not working properly returns no data

Hi i have this query which i want the result to be displayed. Now i have a date here that inputs date. When the data is being passed it returns an empty array. But when the data is static the results will display. Here is my script below

<form action="" method="post">
                
            <p class="mb-3 mb-lg-0">Search for all confirmed booking(s)</p>
            <select name="searchGuests" data-style="btn-selectpicker" title="Search Guest(s)" class="selectpicker form-control" data-live-search="true" >
                @foreach($getBookingGuests as $getBookingGuest)
                        <option value="- ">, </option>
                    @endforeach
            </select>
            <br>
            <br>
             <select name="searchPayment" data-style="btn-selectpicker" title="Search Payment(s)" class="selectpicker form-control" data-live-search="true" >
                    <option value="gcash">Gcash</option>
                    <option value="palawan">Palawan</option>
                    <option value="bpi">BPI</option>
              </select>
              <br>
              <br>
              <select name="searchRooms" data-style="btn-selectpicker" title="Search Room(s)" class="selectpicker form-control" data-live-search="true" >
                    @foreach($getAllRooms as $getAllRoom)
                        <option value=""></option>
                    @endforeach
              </select>
              <br>
              <br>

              <div class="datepicker-container-check">
                <input type="text" name="checkInDate" id="bookingDate" placeholder="Search Booking Date"  class="form-control">
              </div>
             <br> 
                  <input type="submit" class="btn btn-success" value="Search" />
             <br>
             <br>
            </form>

this line in here

<input type="text" name="checkInDate" id="bookingDate" placeholder="Search Booking Date"  class="form-control">

My controller

 $checkInDate = $request->get('checkInDate');
 $checkInDateExp = explode("to", $checkInDate);

 $checkDate = $checkInDateExp[0];
        $checkDateTo = $checkInDateExp[1];

Then my query display

 $getCheckDates  = BookingHistory::orWhereBetween('checkin_date', [$checkDate, $checkDateTo])->where('confirmed', 1)->get()->toArray();

            echo "<pre>";
            print_r($getCheckDates); exit;
            echo "</pre>";

I don't know why it returns an empty array this is the result when passing the data from my form

2019-11-15
2019-12-29

Array
(
)

Can someone help me figured this thing out?. Since the orWhereBetween works when the data is static. Now if the data is passed from the form no display. Any help is muchly appreciated. TIA



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2QRX9Lh
via IFTTT

Aucun commentaire:

Enregistrer un commentaire