简体   繁体   中英

Search in laravel for booking by User id

I'm trying to make search for booking by user id but it's give me all booking for all users I want to know how to retrive all booking by user_id from table booking, Thanks in advance, Please Note that in offline working very well, but online give me all booking for all users.

  <form action="{{url('search',Auth::user()->id)}}" method="get">
    <div class="form-group">
      <label for="Search">Search :</label>
      <input class="form-control" placeholder="Search Here" type="text" name="search">
      <button type="submit" class="btn btn-success btn-mini deleteRecord">Search</button>
    </div>
    </form>
  </div>

Route:

Route::get('search/{id}','BookAppointController@search'); 

Controller:

public function search(Request $request, $id)
{
    $search=$request->get('search');
    $Allappoints=DB::table('bookappoitments')->where('users_id',$id)
    ->where('gustname','like', '%' .$search. '%')
    ->orwhere('gustcompany','like', '%' .$search. '%')
    ->orwhere('gustemail','like', '%' .$search. '%')

    ->join('times','bookappoitments.times_id','times.id')
    ->join('dates','bookappoitments.Dates_id','dates.id')
    ->select('bookappoitments.*','times.from_to','dates.Dates')->orderBy('times.id')
    ->paginate(10);

   return view('admin.ManageTime.All',compact('Allappoints'));


}

Use this format, please

public function search(Request $request, $id)
{
    $search=$request->get('search');
    $Allappoints=DB::table('bookappoitments')->where('users_id',$id)- 
    >paginate(10);

   return view('admin.ManageTime.All',compact('Allappoints'));


}

Tell me if any other issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM