为什么我只退回集合的第一项

时间:2019-03-31 12:21:47

标签: laravel

我有一个脚本来搜索工作人员并返回他们的列表 每个工作人员都有一个“预订我”模式,我希望与每个工作人员的搜索结果集相关联。 问题在于,仅流行模式返回结果集中的第一项…即使不是第一位即时预订的人

好像预订模式位于结果集之外,并且单击它不会保留尝试预订的人的信息

SearchController:


class SearchController extends Controller {
        $Employees=Employee::where(DB::raw('EmployeeService'),'LIKE',"%{$query1}%")
                    ->where('AccentCity','LIKE',"%{$query2}%")
                    ->get();


        Session::put('EmployeeData',$Employees);
        return view('search.results')
                        ->with('Employees',$Employees)

}

结果视图:

@if(!$Employees->count())
    <p>No results found</p>
@else


<div class="panel panel-default">
            <div class="panel-heading"><h3></h3></div>
                <div class="panel-body">
                    <div class="row">
                        <div class="col-lg-12">


                                @foreach($Employees as $Employee)

                                        @include('user/partials/employeeblock')
                                @endforeach



                        </div>
                    </div>
                </div>
            </div>
</div>
@endif

user / partials / employeeblock :(这是问题所在,其中$ Employee-> id仅返回内容的第一项,而不是我感兴趣的那个项)

    <div class="row no-gutters mb-5 mb-lg-0" style="padding:10px">


            @include('templates.partials.bookingform') 


                @if(Auth::check())


                    @if($bookingRequests->count()>0)

                            @if($Employee->id==$bookingRequests->first()->employee_id)
                                    <a href="#" class="btn btn-primary" data-toggle="modal" data-target="#bookingModal">Show Number</a>
                                @else

                                    <a href="{{route('user.BookingItem',['empl_id'=>$Employee->id])}}" class="btn btn-primary" data-toggle="modal" data-target="#bookingModal">Book Me</a>

                            @endif

                        @else

                                    <a href="{{route('user.BookingItem',['empl_id'=>$Employee->id])}}" class="btn btn-primary" data-toggle="modal" data-target="#bookingModal">Book Me</a>
                    @endif

                @else
                                    <a href="{{route('search.searchItem',['serv'=>$Employee->EmployeeService,
                                                                    'suburb'=>$Employee->AccentCity]
                                                                    )}}" class="btn btn-primary" >Book Me</a>
                @endif




                </div>
             </div>

如果您能够将我要预订的员工的数据传递给模式,以便在您单击模式表单上的提交时将其存储在数据库中

0 个答案:

没有答案