简体   繁体   English

在 Laravel 中按用户 ID 搜索预订

[英]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.我正在尝试按用户 ID 搜索预订,但它为我提供了所有用户的所有预订 我想知道如何通过 user_id 从表预订中检索所有预订,提前致谢,请注意,离线工作非常好,但是在线给我所有用户的所有预订。

  <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.告诉我是否还有其他问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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