mysql - no data show in table after adding search by date range and name in laravel -


i have 2 table "patient" , "booking" table, , there relationship "one many" between them, made search form in index_booking page user can type patient_name on search user name according condition search date range , there no data appear in form till search date , don't know why data show default according condition :

this booking model

class booking extends eloquent {      public function patient()     {       return $this->belongsto('app\patient');      }      public function user()     {       return $this->belongsto('app\user');       } } 

this patient model

class patient extends eloquent {     public function booking()     {       return $this->hasmany('app\booking');      }      public function user()     {       return $this->belongsto('app\user');       } } 

and used code in index page of booking

   <div class="search1">            {!! form::open(['method'=>'get','url'=>'booking','class'=>'navbar-form navbar-left','role'=>'search'])  !!}            <!--<span class="badge">{{$bookings->count()}}</span>-->         </div>   <tr>     <div class="col col-md-3">      <p></span><input type="text" id="end" name="end" placeholder="الي تاريخ"><span class="glyphicon glyphicon-calendar"></p>     </div>     <div class="col col-md-4">      <p><input type="text" id="start" name="start" placeholder="من تاريخ"></p>     </div>     <td class="title search col-md-5">     <div class="input-group custom-search-form">      <input type="text" class="form-control" name="search" placeholder="ابحث بالاسم...">      <span class="input-group-btn">          <button class="btn btn-default-sm" type="submit">             <i class="fa fa-search"> <span class="hiddengrammarerror" pre="" data-mce-bogus="1"></span></i>         </button>     </span>  </div>     </td>     {!! form::close() !!} 

i used code in booking controller show data according condition , search date range:

  public function index(request $request) {     $search = request::input('search');   $start = request::input('start');   $end = request::input('end');       $bookings = booking::wherehas('patient', function ($query) use ($search, $start, $end) {     $query->when($start !== null, function ($query) use ($start) {       $query->where('booking_date', '>=', $start)         ->when($end !== null, function ($query) use ($end) {         $query->where('booking_date', '<=', $end);         })->where('status','=', null)->wherehas('patient', function ($query){         $query->where('company_id','=' ,auth::user()->company_id);         });     });   })->where('patient_name', 'like', '%' . $search . '%')   ->wherebetween(db::raw('date(booking_date)'), [$start, $end])      ->orderby("id", "asc")    ->paginate(7);     return view('booking.index')->withbookings($bookings);    } 

javascript code in booking index is:

 <script>           $(function(){$("#start").datepicker({             autoclose:!0,             dateformat:"yy-mm-dd",             startdate:new date         }),         $("#end").datepicker({             autoclose:!0,             dateformat:"yy-mm-dd",             enddate:new date         })     });  


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -