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

      拉拉维尔 |唯一验证 where 子句

      时间:2023-08-20
    4. <tfoot id='A6bXZ'></tfoot>
            <tbody id='A6bXZ'></tbody>
          • <legend id='A6bXZ'><style id='A6bXZ'><dir id='A6bXZ'><q id='A6bXZ'></q></dir></style></legend>
              <bdo id='A6bXZ'></bdo><ul id='A6bXZ'></ul>
              <i id='A6bXZ'><tr id='A6bXZ'><dt id='A6bXZ'><q id='A6bXZ'><span id='A6bXZ'><b id='A6bXZ'><form id='A6bXZ'><ins id='A6bXZ'></ins><ul id='A6bXZ'></ul><sub id='A6bXZ'></sub></form><legend id='A6bXZ'></legend><bdo id='A6bXZ'><pre id='A6bXZ'><center id='A6bXZ'></center></pre></bdo></b><th id='A6bXZ'></th></span></q></dt></tr></i><div id='A6bXZ'><tfoot id='A6bXZ'></tfoot><dl id='A6bXZ'><fieldset id='A6bXZ'></fieldset></dl></div>

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

              • 本文介绍了拉拉维尔 |唯一验证 where 子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在尝试验证存在的电子邮件地址的输入,但仅当 company_id 与随请求传入的 company_id 相同时才有效.

                I am trying to validate the input of a email address that exists but only when the company_id is the same as the company_id which is passed in with the request.

                我收到此错误...

                SQLSTATE[42S22]:未找到列:1054 'where 子句'中的未知列 '1'(SQL:选择 count(*) 作为来自 company_users 的聚合,其中 email_address = myemail.com 和 1 <> company_id)

                SQLSTATE[42S22]: Column not found: 1054 Unknown column '1' in 'where clause' (SQL: select count(*) as aggregate from company_users where email_address = myemail.com and 1 <> company_id)

                我在网上阅读过,这样做的方法是将验证中的表和列关联起来,这就是我正在做的.

                I have read online and the way to do it is to associate the table and the column inside of the validation which is what I am doing.

                这是我当前的代码...

                This is my current code...

                required|email|unique:company_users,email_address,company_id,' . $request->company_id
                

                推荐答案

                这里有一个粗略的想法,你可以实现你的目标

                Here is a rough idea with this you can achieve what you

                您可以使用 Rule 类为您自定义验证规则.

                You can use Rule class to customize the validation rule for you.

                'email' => ['required', 'string', 'email', 'max:191',Rule::unique('users')->where(function ($query) use ($request) {
                    return $query->where('company_id', $request->company_id);
                })],
                

                希望能帮到你

                这篇关于拉拉维尔 |唯一验证 where 子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:合并来自两个不同数据库的表 - sqlite3/Python 下一篇:如何最好地设计具有多个过滤器的 REST API?

                相关文章

                最新文章

              • <small id='xMwRa'></small><noframes id='xMwRa'>

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