1. <legend id='EIPbS'><style id='EIPbS'><dir id='EIPbS'><q id='EIPbS'></q></dir></style></legend>
    <tfoot id='EIPbS'></tfoot>
    <i id='EIPbS'><tr id='EIPbS'><dt id='EIPbS'><q id='EIPbS'><span id='EIPbS'><b id='EIPbS'><form id='EIPbS'><ins id='EIPbS'></ins><ul id='EIPbS'></ul><sub id='EIPbS'></sub></form><legend id='EIPbS'></legend><bdo id='EIPbS'><pre id='EIPbS'><center id='EIPbS'></center></pre></bdo></b><th id='EIPbS'></th></span></q></dt></tr></i><div id='EIPbS'><tfoot id='EIPbS'></tfoot><dl id='EIPbS'><fieldset id='EIPbS'></fieldset></dl></div>

      <small id='EIPbS'></small><noframes id='EIPbS'>

        <bdo id='EIPbS'></bdo><ul id='EIPbS'></ul>
    1. Laravel 过滤所有列中的值

      时间:2023-09-23

        <bdo id='KnHoa'></bdo><ul id='KnHoa'></ul>
        <legend id='KnHoa'><style id='KnHoa'><dir id='KnHoa'><q id='KnHoa'></q></dir></style></legend>
        • <small id='KnHoa'></small><noframes id='KnHoa'>

        • <tfoot id='KnHoa'></tfoot>

                <i id='KnHoa'><tr id='KnHoa'><dt id='KnHoa'><q id='KnHoa'><span id='KnHoa'><b id='KnHoa'><form id='KnHoa'><ins id='KnHoa'></ins><ul id='KnHoa'></ul><sub id='KnHoa'></sub></form><legend id='KnHoa'></legend><bdo id='KnHoa'><pre id='KnHoa'><center id='KnHoa'></center></pre></bdo></b><th id='KnHoa'></th></span></q></dt></tr></i><div id='KnHoa'><tfoot id='KnHoa'></tfoot><dl id='KnHoa'><fieldset id='KnHoa'></fieldset></dl></div>

                  <tbody id='KnHoa'></tbody>
                本文介绍了Laravel 过滤所有列中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                public function getBooks($input)
                {
                    $books= Book::where('book_name', 'LIKE', '%' . $input . '%')->get();
                    return Response::json($books);
                }
                

                我知道如何按给定值过滤列.但是如何按给定值过滤所有列.例如,我有一个名为类别"的列,用户应该能够使用相同的搜索栏来过滤类别.

                I know how to filter a column by a given value. But how do I filter ALL columns by a given value. For example, I have a column called 'category' where user should be able to use the same search bar to filter the category.

                类似于:

                $books = Book::where('all_columns', 'LIKE', '%' . $input . '%')->get();
                

                谢谢!

                推荐答案

                大多数数据库不支持同时搜索所有列.恐怕您可能不得不将所有列链接在一​​起:

                Most databases do not support searching all columns simultaneously. I'm afraid you'll likely have to chain all of the columns together:

                $books = Book::where('book_name', 'LIKE', '%' . $input . '%')
                    ->orWhere('another_column', 'LIKE', '%' . $input . '%')
                    // etc
                    ->get();
                

                这篇关于Laravel 过滤所有列中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:Laravel 使用 Eloquent 的多对多关系 下一篇:如何在 Laravel 的 Eloquent ORM 中按数据透视表数据排

                相关文章

                最新文章

                  <bdo id='NyCkQ'></bdo><ul id='NyCkQ'></ul>
                1. <i id='NyCkQ'><tr id='NyCkQ'><dt id='NyCkQ'><q id='NyCkQ'><span id='NyCkQ'><b id='NyCkQ'><form id='NyCkQ'><ins id='NyCkQ'></ins><ul id='NyCkQ'></ul><sub id='NyCkQ'></sub></form><legend id='NyCkQ'></legend><bdo id='NyCkQ'><pre id='NyCkQ'><center id='NyCkQ'></center></pre></bdo></b><th id='NyCkQ'></th></span></q></dt></tr></i><div id='NyCkQ'><tfoot id='NyCkQ'></tfoot><dl id='NyCkQ'><fieldset id='NyCkQ'></fieldset></dl></div>
                  <legend id='NyCkQ'><style id='NyCkQ'><dir id='NyCkQ'><q id='NyCkQ'></q></dir></style></legend>

                  <small id='NyCkQ'></small><noframes id='NyCkQ'>

                2. <tfoot id='NyCkQ'></tfoot>