php - 如何在 Laravel 中过滤后显示消息?

标签 php laravel

选择过滤器后,我想显示我们选择的摘要选项卡/消息。 我用谷歌搜索并找到了 session 方法,它适合我的情况吗? 这是我的 Blade

   {!! Form::open(['url'=>'/jobseekers','method'=>'GET', 'class'=>'form', 'id'=>'search_data']) !!}

              <div class="form-group col-md-4">

                <input type="text" name="fullname" placeholder="Name" value="{{ request()->input('fullname')}}" class="form-control"/>
              </div>
                        <div class="form-group col-md-4">
                            
                            <input type="text" name="fb_name" placeholder="Fb Name" value="{{ request()->input('fb_name')}}" class="form-control"/>
                        </div>
                          <button class="btn btn-flat btn-primary">Search</button>
              </div>
              {!! Form::close() !!}

在我的 Controller 中

public function index(Request $request)
    {
        $result = null;
        if(count($request->all())!=0){  
            if ($request->has('sub_search')) {
                $jobseekers = Jobseeker::Subsearch($request)->paginate(10); 
                dd($applicant_information);

            }else{
                $result=Jobseeker::Search($request)->paginate(10);  
              //  dd($orders);
            } 

        }
        else{
     
            $jobseekers = Jobseeker::with('calllogs')->orderBy('created_at', 'desc')->paginate(16);
        }       


       return view('backend.jobseekers.index',compact('jobseekers','result')); 
    }
    

我正在使用 get 方法来过滤,我想显示为

The Search results for fullname and fb_name are:

对于我的情况,有什么办法可以做到这一点吗?请指导我,谢谢。

最佳答案

您是否尝试在 View 中显示过滤结果?如果是这样,请将您的代码更改为:-

public function index(Request $request)
    {
        $fullname = $request->fullname;
        $fb_name= $request->fb_name;
        $result = null;
        if(count($request->all())!=0){  
            if ($request->has('sub_search')) {
                $jobseekers = Jobseeker::Subsearch($request)->paginate(10); 
                dd($applicant_information);

            }else{
                $result=Jobseeker::Search($request)->paginate(10);  
              //  dd($orders);
            } 

        }
        else{

            $jobseekers = Jobseeker::with('calllogs')->orderBy('created_at', 'desc')->paginate(16);
        }       


       return view('backend.jobseekers.index',compact('jobseekers','result'))->with('fullname',$fullname)->with('fb_name',$fb_name); 
    }


您所需要做的就是从该 Controller 访问传递的变量,就像

{{$fullname}} 和 {{$fb_name}} 的搜索结果为:

并在此处循环结果...

关于php - 如何在 Laravel 中过滤后显示消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45530188/

相关文章:

php - Laravel 模型是使用 id = 0 创建的

Laravel 5.3 auth 方法实现/覆盖

php - YII - 单元测试不起作用

php - 从服务器检索的JSON对象上的SearchView

php - 您如何看待这个解决方案而不是使用表名作为 PDO 参数?

php - Laravel : Setting dynamic routes based on access control list

php - Laravel 5.4 - 注册后自动登录

php - 在 apache 中限制从 Internet 访问

php - 根据另一个下拉列表的输入显示下拉列表时出错

php - Laravel 子域 : single auth across all subs not working?