首页 > 解决方案 > Laravel:即使在laravel中与其他人一样,如何做身份号码也不应该是相同的

问题描述

晚上好。目前我面临为一个人保存身份证号码的问题。每个人应该有不同的身份号码。如果识别号相同意味着数据不应该保存,但在我的情况下,即使具有相同的数据也会保存数据。任何人都可以在这方面提供帮助吗?

检查数据是否存在

  public function check_child_birth_cert(){ 

        if(Child::where('child_birth_certificate_no')
                ->exists()){
           return "exist";
        }else{                                                                    
           return "not exist";
        }
    }

创建数据

'child_data.child_birth_certificate_no':function(){
                axios.get('check_child_birth_cert/'+ this.pros.child_birth_cert)
                    .then(reponse =>{
                        this.child_birth_certificate_no=reponse.data;
                    })
            }

调用函数 repo 到控制器

public function getchildBirth_cert(Request $request){

        $this->childRepository->check_child_birth_cert($request->all());

    }

标签: phpjquerydatabaselaravel

解决方案


检查 Laravel 码头https://laravel.com/docs/7.x/queries#where-clauses。你写了where没有选项的语句,在哪里列child_birth_certificate_no什么?也许等于什么?^_^


推荐阅读