Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel 5.4或Wherebetween查询无法正常工作时不会返回任何数据_Php_Laravel 5 - Fatal编程技术网

Php Laravel 5.4或Wherebetween查询无法正常工作时不会返回任何数据

Php Laravel 5.4或Wherebetween查询无法正常工作时不会返回任何数据,php,laravel-5,Php,Laravel 5,嗨,我有这个查询,我想显示结果。现在我这里有一个日期,输入日期。当传递数据时,它返回一个空数组。但当数据是静态的时,结果将显示出来。下面是我的脚本 <form action="{{ action('TotalSaleController@searchConfirmed') }}" method="post"> {{ csrf_field() }} <p class="mb-3 mb-lg-0">Search for

嗨,我有这个查询,我想显示结果。现在我这里有一个日期,输入日期。当传递数据时,它返回一个空数组。但当数据是静态的时,结果将显示出来。下面是我的脚本

<form action="{{ action('TotalSaleController@searchConfirmed') }}" method="post">
                {{ csrf_field() }}
            <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="{{ $getBookingGuest['first_name'] }}-{{ $getBookingGuest['last_name'] }} ">{{ $getBookingGuest['first_name'] }}, {{ $getBookingGuest['last_name'] }}</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="{{ $getAllRoom['id'] }}">{{ $getAllRoom['property_name'] }}</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>
然后显示我的查询

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

            echo "<pre>";
            print_r($getCheckDates); exit;
            echo "</pre>";
有人能帮我弄清楚这件事吗?。因为当数据是静态的时,
或where-between
起作用。现在,如果数据从表单传递,则不显示。非常感谢您的帮助。TIA

我希望这能有所帮助


谢谢我已经解决了!checkinDate和CheckoutDate我只添加了strottime。而且它有效!
 $checkInDate = $request->get('checkInDate');
 $checkInDateExp = explode("to", $checkInDate);

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

            echo "<pre>";
            print_r($getCheckDates); exit;
            echo "</pre>";
2019-11-15
2019-12-29

Array
(
)
 $getCheckDates  = BookingHistory::where('confirmed', 1)
              ->whereBetween('checkin_date', [$checkDate, $checkDateTo])
              ->get();
if($getCheckDates) {
  $getCheckDates = $getCheckDates->toArray(); # you may let it be object also
} else {
   // no any query result
}