Laravel 4多个搜索字段

DommT

我正在Laravel 4应用程序中创建搜索功能。

它运行良好,因为它运行良好,这是非常好的功能,这是我在邮政编码字段中进行搜索(例如)并单击搜索时唯一的事情。

我希望搜索的值保留在文本输入中。就像将值设置为标准PHP / HTML中的php变量一样。

我已经包含了控制器功能和一个文本输入字段,供您在下面查看。任何帮助将不胜感激,谢谢。

public function postSearch()
{
    $search_order_from_date = Input::get('search_order_from_date');
    $search_order_to_date = Input::get('search_order_to_date');
    $search_order_type = Input::get('search_order_type');
    $search_order_status = Input::get('search_order_status');
    $search_order_agent = Input::get('search_order_agent');
    $search_order_assessor = Input::get('search_order_assessor');
    $search_order_postcode = Input::get('search_order_postcode');

    $orders = DB::table('orders')
    // ->where('order_date', '>=', $search_order_from_date, 'and', 'order_date', '<=', $search_order_to_date, 'or')
    ->orWhere('type', '=', $search_order_type)
    ->orWhere('epc_status', '=', $search_order_status)
    ->orWhere('agent', '=', $search_order_agent)
    ->orWhere('assessor', '=', $search_order_assessor)
    ->orWhere('postcode', '=', $search_order_postcode)
    ->orderBy('order_date', 'DESC')
    ->paginate();
    Session::put('search', 'search query');
    $users = User::all();
    $userType = Session::get('type');
    $perms = DB::table('permissions')->where('user_type', $userType)->first();
    $this->layout->content = View::make('orders.index', compact('orders'), compact('perms'));
}



{{Form :: text('search_order_postcode',null,array('class'=>'form-control','placeholder'=>'Order Postcode'))}}

里克·兰斯(Rick Lancee)

您可以将search_order_postcode传递到您的视图。

$this->layout->content = View::make('orders.index', compact('orders', 'search_order_postcode'), compact('perms'));

将其添加到索引视图或创建初始搜索表单视图的任何位置,这样就不会出现错误(如果不存在)。
编辑:还将其从控制器传递到搜索视图。

$search_order_postcode = (isset($search_order_postcode) && $search_order_postcode !== '') ? $search_order_postcode : null;

然后在您看来:

// Search_order_postcode is either the value it was given or null
{{ Form::text('search_order_postcode', $search_order_postcode, array('class'=>'form-control', 'placeholder'=>'Order Postcode')) }}

重复冲洗其他输入,或将它们存储在数组中,以免膨胀您的view :: make,但这是个人喜好。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Laravel 4分页的多个视图

来自分类Dev

在Laravel 4中获取查询字段信息

来自分类Dev

PHP(Laravel 4)和PostgreSQL搜索

来自分类Dev

Laravel具有多个条件的搜索查询

来自分类Dev

空搜索结果Laravel 4

来自分类Dev

在Laravel 4中跨多个表进行全文搜索

来自分类Dev

Laravel / Blade下拉列表-多个字段

来自分类Dev

laravel搜索由空格分隔的多个单词

来自分类Dev

Laravel 4获取多个集合

来自分类Dev

elastic4s-在多个字段中搜索

来自分类Dev

Rails 4中的多个搜索字段

来自分类Dev

laravel 5搜索多个字段

来自分类Dev

laravel多字段搜索表单

来自分类Dev

从在Laravel搜索多个不同的表中显示的数据

来自分类Dev

Laravel:使用多个搜索条件,获得入门

来自分类Dev

使用Laravel的WhereIn搜索多个表

来自分类Dev

Laravel 4/5搜索表单,例如

来自分类Dev

使用Laravel 4创建搜索功能

来自分类Dev

PHP(Laravel 4)和PostgreSQL搜索

来自分类Dev

在Laravel 4中创建搜索功能

来自分类Dev

对Laravel 4中的多个字段求和

来自分类Dev

空搜索结果Laravel 4

来自分类Dev

Laravel 4-产品搜索服务

来自分类Dev

elastic4s-在多个字段中搜索

来自分类Dev

使用laravel 5从多个相关表中搜索渴望加载

来自分类Dev

Laravel具有多个表的搜索数据库

来自分类Dev

在 Laravel 中填充多个选择字段

来自分类Dev

多个数组 (Laravel 4)

来自分类Dev

Algolia:在 Laravel 中搜索多个索引