所以,我的代碼中有一些錯誤,當(dāng)我輸入姓名、專業(yè)和城市時,我希望搜索框能工作,但它不再工作了,所以這是我的控制器代碼: public function chercher (Request $request) { $doctors=medecin::orderBy('created_at','desc')->get(); $rech=$request->get('rech'); $spec=$request->get('spec'); $ville=$request->get('Région'); $S=medecin::orderBy('created_at','desc')->get() ->where('Spécialité',$spec) ; $SV=medecin::orderBy('created_at','desc')->get() ->where('Spécialité',$spec) ->where('Ville',$ville); $SN=medecin::orderBy('created_at','desc')->get() ->where('Spécialité',$spec) ->where('Nom',$rech) ; $SNV=medecin::orderBy('created_at','desc')->get() ->where('Spécialité',$spec) ->where('Nom',$rech) ->where('Ville',$ville); $V=medecin::orderBy('created_at','desc')->get() ->where('Ville',$ville); $N=medecin::orderBy('created_at','desc')->get() ->where('Nom',$rech); $NV=medecin::orderBy('created_at','desc')->get() ->where('Nom',$rech) ->where('Ville',$ville) ; return view ('doctors' ,['doc'=> $doctors,$S,$SV,$SN,$SNV,$V,$N,$NV],['tab'=>[$rech,$spec,$ville]]); }這是視圖:{{$tab[0]}}{{$tab[1]}}{{$tab[2]}} <ul> @if($tab[1]=='Dentiste' && $tab[2]=='Tunis' && $tab[0]=='' ) @foreach($doc[0] as $show)<h1> Dr.{{$show->Nom}} {{$show->Prénom}} </h1> </br> <h1> {{$show->Photo}} </h1><h1>{{$show->Spécialité}} </h1><h1>{{$show->Ville}}</h1>@endforeach @elseif($tab[1]=='' && $tab[2]=='' ) @foreach($doc[2] as $show) <h1> Dr.{{$show->Nom}} {{$show->Prénom}} </h1> </br> <h1> {{$show->Photo}} </h1><h1>{{$show->Spécialité}} </h1><h1>{{$show->Ville}}</h1>@endforeach@elseif ($tab[0]=='' && $tab[2]='')@foreach ($doc[7] as $show)<h1> {{$show->Nom}} {{$show->Prénom}} </h1> </br> <h1> {{$show->Photo}} </h1><h1>{{$show->Spécialité}} </h1><h1>{{$show->Ville}}</h1>@endforeach如果我單擊搜索按鈕,則會出現(xiàn)此錯誤:試圖獲取非對象的屬性“Nom”(查看:C:\xampp\htdocs\Doctor\resources\views\doctors.blade.php)
試圖獲取非對象的屬性“Nom”
慕碼人2483693
2022-10-09 19:55:48